Introduction: Don’t Be Afraid of Servers
Why you should consider hosting your project on a VPS?
For many years, PaaS and serverless services have claimed that managing servers and self-hosting is highly complex, trying to push their services as much as possible. We've used both PaaS and serverless solutions for years before returning to a combination of VPS (cloud servers), bare-metal servers, and on-premise setups (machines in the office or even at home). The main issue with self-hosting is the lack of a clear, step-by-step guide on how to deploy a project on a cloud server from scratch. That’s why we created this book (or guide), where you’ll find everything you need to deploy your projects on cloud servers, dedicated servers, old laptops, and single-board computers.
Before we start deploying, let’s explore why you should definitely consider hosting your next web or IoT project on a VPS or bare-metal server:
- Fully Predictable Pricing: With VPS, you can fully predict cloud costs, even in the event of a DDoS attack. In contrast, serverless pricing is highly unpredictable since you pay per usage. For example, one month you might have 1,000 visitors and pay a few dollars, but the next month, a sudden spike in traffic (whether from users or bots) could lead to millions of requests per day, and your cloud bill could easily skyrocket to hundreds or even thousands of dollars. On the other hand, a VPS instance costing $5-$15 per month can handle traffic spikes without such extreme costs.
- Flexibility: With VPS and bare-metal servers, you have the freedom to install whatever you need. For instance, if you need to process images or videos after a user uploads a file, you often require command-line tools or external binaries. With serverless and traditional PaaS, running such binaries is not an option. On a VPS, you can do everything on a single server—process API calls, schedule tasks, and even scale by offloading processing to another server in the same data center if traffic increases. Another example is deploying projects using WebSockets or other two-way protocols. Deploying WebSockets on serverless is nearly impossible, and it can be tricky on some PaaS platforms, while it’s quick and straightforward with VPS.
- Full Control Over Data: With self-hosting, you have complete control over your data, ensuring privacy and compliance with regulations, something that can be difficult with third-party services.
- Zero Vendor Lock-in: When you use any proprietary service, you're locked into that service. For example, if you're using AWS Lambda, you must follow AWS-specific rules. This ties you to AWS infrastructure, and if you decide to migrate to a VPS after receiving a large bill, it could take weeks or even longer for complex projects—not just a few hours. With a VPS, you're not locked into any cloud provider. It's just a server running Linux, so you can easily migrate between cloud providers or even to your own hardware (e.g., old laptops or single-board computers).
- No Need for Additional 3rd-Party Services: For example, setting up CI/CD for serverless functions or certain PaaS solutions often requires additional services like GitHub Actions, container registries, etc. With a VPS, you can handle everything yourself for as little as $5-$10 per month.
Why Self-Hosting is Easier Than You Think
VPS, cloud servers, or dedicated managed servers are essentially just standard computers, like your laptop or desktop, connected to the internet. Hosting a project on a server is no different from running tools, utilities, or binaries on your local machine during development. The only task is to start a few tools on the server. However, many guides tend to overcomplicate this process. That’s why we created this book, which provides simple step-by-step setups:
- You can host all parts of your project on a single server.
- You can host different parts of your project on multiple servers, even across different locations and cloud providers. For more advanced setups, you can mix cloud servers with on-premise machines at your office or home.
Questions We Cover in This Book
- Where to order a server and how to log in.
- How to deploy a project from your local machine, GitHub, Bitbucket, or GitLab.
- How to connect a custom domain with automated TLS certificates.
- How to scale resources based on the number of requests and overall server load.
- How to mitigate attacks and apply rate-limiting.
- How to deploy on multiple servers and balance requests between them.
- How to secure your servers.
- How to set up CI/CD, including container registries.