Learning objectives
After reading this article you will be able to:
- Understand how a VPS works under the hood
- Know what becomes your responsibility when you rent one
- Decide whether your project needs a VPS or something simpler
When your project leaves your home computer and needs to stay online all day, the first suggestion you usually hear is "rent a VPS". It is a good answer in many cases, but it comes with a bill almost nobody mentions: along with the server, you inherit the work of running it.
What is a VPS?#
VPS stands for Virtual Private Server. In Wikipedia's definition, it is a virtual machine sold as a service by a hosting company.
In practice, you pay monthly for a computer that does not exist as a separate physical box. It is a slice of a real machine, with a fixed amount of CPU, RAM and disk, a public IP address and an operating system of your own, usually Linux. You log in through a terminal and do whatever you want, within the limits of the contract.
How does a VPS work under the hood?#
A large physical server runs a hypervisor, the software that creates and runs the virtual machines. Each virtual machine (the "guest") sees only the resources reserved for it and can be rebooted without affecting the others.
Two points matter to you:
- Each VPS has its own operating system. With hardware virtualization, such as KVM, each machine even has its own kernel, which gives more isolation from the physical server. With container-based virtualization, the host kernel is shared: more instances fit on each machine, but isolation is weaker and you can customize less.
- Physical resources are shared. Since several VPSs split the same machine, each one gets a cap on CPU, RAM and disk. Depending on the neighbors' load, performance can fluctuate.
If the difference between a virtual machine and a container is still fuzzy, see containers vs virtual machines.
What do you get when you rent a VPS?#
Usually four things: a public IP, root access (or a user with sudo), a preinstalled system image (Ubuntu, Debian and similar) and a provider dashboard to start, stop, reinstall and sometimes resize the machine.
After that, the server is yours. It arrives practically empty, and everything that runs on it was installed by you.
What do you have to maintain?#
This is the point that decides whether a VPS is worth it. The provider maintains the hardware and the network. The rest is on you:
- System updates. Outdated packages with known flaws are a classic way in for attackers.
- Access security. SSH key authentication, a firewall and users without unnecessary privileges.
- Running the application reliably. If the process crashes or the machine reboots, something has to bring it back.
- HTTPS, a reverse proxy and certificates, if you serve a website or API.
- Monitoring, logs and copies of your data.
A minimal first hardening step on a fresh Ubuntu server is to update the system and enable the firewall allowing only SSH (the ufw commands are in the Ubuntu documentation):
sudo apt update && sudo apt upgrade -y
sudo ufw allow ssh
sudo ufw enable
sudo ufw status verboseRun ufw allow ssh before ufw enable. Turning on the firewall without allowing SSH cuts off your own connection.
And that is only the beginning. You still need a process supervisor, the proxy, the certificate and automatic updates. Each item is simple on its own, but together they add up to hours of maintenance every month.
VPS, dedicated server and shared hosting: what is the difference?#
| Shared hosting | VPS | Dedicated server | |
|---|---|---|---|
| What you rent | An account on a shared server | A virtual machine | The whole physical machine |
| Root access | No | Yes | Yes |
| Isolation | Low | Medium to high | Full |
| Performance | Varies with neighbors | Can vary with neighbors | Predictable |
| Administration | Almost none | All yours | All yours |
| Cost | Lowest | Middle | Highest |
For many purposes, a VPS behaves like a dedicated server, with the advantage of being created in minutes and costing less. To see what goes into the price, see how much a VPS costs.
When do you need a VPS?#
A VPS makes sense when you need control over the system:
- Software that needs access to the whole system, such as a network service, a VPN or a kernel module.
- An unusual stack that does not fit the standard runtimes of hosting platforms.
- Several different services on the same machine, configured your way.
- Learning: running a real Linux server teaches you a lot about deployment, networking and security.
- Compliance requirements that demand control of the operating system.
When is a VPS not the best choice?#
If your project is a bot, an API or a regular website, what you want is the process online, not a server to look after. In that case, a VPS charges you in time: you become the sysadmin of a project that only needed a node index.js running.
Signs that you are carrying too much weight:
- You spend more time in the server's terminal than in your code.
- A system security advisory becomes your emergency of the week.
- The bot went down at night and nobody noticed, because automatic restart was never set up.
For this kind of workload, a hosting platform that runs your code in containers is usually simpler. The full comparison is in VPS vs hosting platform.
How to do this on Square Cloud#
If your goal is to keep an application online without building a server, Square Cloud is self-service hosting: you deploy and control the application, which runs in an isolated container. You do not install an operating system, a firewall or a proxy.
Containers are always on, with no sleep mode, and automatic restart (on by default for dashboard deploys) when the process exits with an error. You deploy by uploading a ZIP in the dashboard, through the CLI, from GitHub or with the VS Code extension. Among several runtimes, such as Node.js, Python, Java and Go, there is one for static sites (see the ones available today on Runtimes), and HTTPS comes automatically for web applications.
What the platform is not: a machine with root access. The process runs as an unprivileged user, and there is no Dockerfile or custom image. If your case requires control of the whole system, a VPS is still the right tool. If it only requires keeping your code running, see the Square Cloud features.
Deploy
Push from GitHub, the CLI or a ZIP and go live in seconds
FAQs
Are a VPS and a dedicated server the same thing?
No. With a dedicated server you rent the whole physical machine. With a VPS you rent a virtual slice of a machine that other customers also use, which costs less but can suffer from the neighbors' load.
Do I need to know Linux to use a VPS?
In practice, yes. You connect through a terminal (SSH), install packages, configure a firewall and keep the system updated. Without that foundation, maintenance becomes the biggest cost of the project.
Can a VPS host a bot, an API or a website?
It can host all three, and anything else that runs on the system you choose. The trade-off is that you set up the process, automatic restarts, HTTPS and security yourself.
What is the difference between a VPS and the cloud?
A VPS is a fixed-size virtual machine. Infrastructure clouds also sell virtual machines, but with many other services around them. In practice, a cloud instance used as a server behaves like a VPS.
More in Deploy
See all 33 articles- What are environment variables?Environment variables are key-value pairs the operating system hands to a process at startup. Learn to read them in Node.js and Python and keep tokens out of code.
- What is a deployment?A deployment takes a version of your code to a server, prepares it and starts it. See the stages, the methods and how to roll back when it goes wrong.
- How much RAM and CPU does my app need?Size RAM and CPU by measuring your app's real peak and adding about 30% headroom. Learn how to measure in Node.js, Python and Java and what to do if short.
- Automatic deploys with GitHub ActionsAutomatic deploys with GitHub Actions ship your code to the server on every push. See the workflow step by step, secrets, tests before deploy and common errors.