Elements vs DigitalOcean

Markdown

DigitalOcean is a cloud provider, founded in 2011 and based in New York, that rents servers and storage to developers and small businesses. Its core product is the Droplet, a virtual Linux server billed by the second up to a fixed monthly price that includes its disk and a data transfer allowance. Around Droplets, DigitalOcean sells managed databases such as PostgreSQL, MySQL and MongoDB, object storage called Spaces, load balancers, managed Kubernetes, and App Platform, a service that builds and runs apps from a Git repository. It is known for a short path from sign-up to a running server and for its large library of tutorials.

Elements is not a cloud provider. It is an integrated app environment for building web apps, built for people and their agents: one coherent system that includes a project server that runs while you work, a default app framework, a package installer, a test runner, a bundled Postgres database, and a deploy command. It deploys to ordinary Ubuntu servers you rent from any provider and reach over SSH, and a Droplet is one. Elements charges for that tooling, per machine, and meters nothing (pricing).

Together, a Droplet and Elements do the job of a hosted platform such as Vercel, on a server you can log in to. DigitalOcean rents the machine at a fixed monthly price. Elements sets it up to run your app, with its database, HTTPS and load balancing. Then it ships each change, often in under a second, and holds back any release whose tests fail. The bill is a Droplet at DigitalOcean's listed price and an Elements license per machine.

One Droplet Runs a Complete Elements App

Elements deploys to any server you can reach over SSH that runs Ubuntu. A Droplet fits that exactly. DigitalOcean says a new one is "up and running in under a minute", monitoring and cloud firewalls cost nothing extra, and Basic Droplets are sold at a fixed monthly price that includes memory, SSD and transfer (pricing).

On that one Droplet, the first deploy sets up the app and everything it runs with: its job worker, the load balancer with certificates from Let's Encrypt, and the same bundled Postgres you develop against (what deploy does). What you do not set up: a separate database server, a web server or reverse proxy, a certificate tool, a process manager, or systemd units.

Elements on a Droplet Does the Job of App Platform and Vercel

DigitalOcean offers two ways to run an app. One is a Droplet, where you control the server. The other is App Platform, "a fully managed Platform-as-a-Service (PaaS) that deploys applications from Git repositories or container images", the same kind of service Vercel sells.

With Elements, the Droplet is all you need, because building and deploying are part of Elements. On your own machine, the project server runs while you work and holds the build graph and build state in memory; on every save the build state is updated almost instantly. It builds in milliseconds and answers agents and humans in microseconds. The Droplet runs a project server too, and elements deploy connects the two over SSH, so only the files that changed cross the wire (deploy). The Droplet's project server keeps its build state between deploys, so it redoes only the work those files require, and a deploy after the first usually finishes in under a second (what deploy does).

On the Droplet, Elements runs the app's tests and applies pending migrations, then swaps in the new release in one atomic step. If a test or a migration fails, nothing is released and the previous version keeps serving (what deploy does). elements deploy -json reports every step on every machine in one structured result, so you and your agent see what happened without opening a shell. A second Droplet makes a staging environment, deployed with elements deploy staging (environments).

DigitalOcean charges for the Droplet, and Elements charges for the tooling: one license per machine that runs it, the Droplet included (licenses). Requests, bandwidth, build minutes and agent work never appear on the Elements bill. Elements vs Vercel compares this setup with a hosted platform in full.

More Droplets Share One Managed Postgres

Each deploy machine runs its own bundled Postgres by default, because the scaffolded production.env sets DB_HOST=127.0.0.1 (setup). That suits a prototype or an app on one Droplet. For several Droplets, or when you want backups and scaling run for you, Elements recommends DigitalOcean Managed PostgreSQL. It is priced per node at a fixed monthly rate (pricing), and it offers daily backups with point-in-time restore to any moment in the previous seven days, standby nodes with automatic failover, and read-only nodes.

Set DB_HOST and the other DB_* values in production.env to the cluster's connection details. Elements connects over TLS and creates the app and test databases on an empty cluster, starting from the defaultdb database every DigitalOcean cluster comes with (database CLI). Then add each Droplet's public and private IP addresses to config.jsoc and point your domain at them. Every machine's load balancer spreads requests across all of them and retries another when one fails (load balancer). Migrations run once, on the first machine.

DigitalOcean or AWS

DigitalOcean and AWS both rent Ubuntu servers, and Elements deploys to each the same way. DigitalOcean asks for fewer choices at launch and folds more into one price: an EC2 instance on AWS also needs a security group, and its public IPv4 address is billed separately. AWS, for its part, offers more managed services. See Elements vs AWS.

From a New Droplet to a Live App

Create an Ubuntu Droplet with your SSH key, and point your domain's A record at its IP address. If you attach a cloud firewall, allow ports 22, 80 and 443: SSH for deploys, and HTTP and HTTPS for the load balancer, which also answers Let's Encrypt on port 80 (load balancer). Add the Droplet's public IP address and your domain to config.jsoc, then run:

elements deploy

The first deploy takes a few seconds. The walkthrough covers each step.

Questions

How do I deploy an Elements app to a DigitalOcean Droplet?

Create an Ubuntu Droplet, add its public IP address and your domain to config.jsoc, and run elements deploy. The first deploy installs Elements on the Droplet and sets up Postgres, the load balancer and HTTPS certificates in a few seconds.

Do I need DigitalOcean App Platform for Elements?

No. App Platform is a managed build and deploy service, and Elements already builds, tests, migrates and deploys the app itself. A plain Droplet is all it needs.

Does Elements work with DigitalOcean Managed PostgreSQL?

Yes. Set DB_HOST and the other DB_* values in production.env to the cluster's connection details. Elements connects over TLS, starts from the defaultdb database every DigitalOcean cluster has, and creates the app and test databases.

What size Droplet do I need for Elements?

A Basic Droplet with 2 GB of memory is enough to start (pricing), since one machine runs the app, the load balancer and Postgres together. When you outgrow it, resize the Droplet, or move the database to Managed PostgreSQL and add more Droplets.

Is DigitalOcean or AWS better for hosting an Elements app?

Both run Elements the same way, over SSH on Ubuntu. DigitalOcean has fewer choices to make at launch and includes disk and transfer in the Droplet price; AWS offers more managed services, such as SES for email and CloudFront for a CDN.