Essential Settings to Configure When Migrating Your Server from Vercel to a VPS
The Vercel free plan hits a ceiling as projects grow. Even a slight increase in traffic can lead to difficult-to-manage costs, eventually leading many to turn to a VPS. Running your own server makes costs predictable, but it leaves you with the homework of deployment and management. Unless you automate this process, you will end up spending more time on server administration than you did with Vercel.
Reducing Deployment Time with GitHub Actions
Manually accessing your server via SSH to run commands is inefficient. It is prone to mistakes, and you have to worry about service interruptions every time you deploy. By building an automation pipeline, you can complete deployments with a single code push.
- Create a dedicated user for deployment on your server and grant it Docker group permissions.
- Store your SSH private key and server IP in GitHub Secrets.
- Write a YAML file to build the Docker image and create a script that runs the container on the remote server.
This approach eliminates manual tasks. By standardizing the server environment, you can lower the possibility of errors occurring.
Breaking Through the Memory Limits of a $5 Server
Low-spec VPS instances, such as those costing around $5 per month, often have only 1GB of RAM. If you run both the web server and the database simultaneously, the OOM (Out of Memory) killer will forcibly terminate your processes. Offload the server load by using external services like Supabase for your database.
To prevent your server from crashing, swap memory is essential.
- Create a 2GB swap file on your server disk.
- Set the kernel's swappiness value between 10 and 20. This adjusts the system to use physical memory as much as possible and only rely on swap when necessary.
This configuration prevents the server from freezing during large builds.
How to Detect Failures in Real-Time
While managed platforms handle failure response for you, a VPS requires you to monitor it yourself. Process management and resource monitoring are not choices; they are survival tools.
- Use PM2 to run your application and apply the
max-memory-restart option. If a memory leak occurs, the process will automatically restart itself.
- Install Netdata and integrate it with Slack. Set thresholds to receive notifications when CPU usage exceeds 80% or when RAM is running low.
- Utilize Rclone to set up a Cron Job that automatically uploads database dumps to Cloudflare R2 every morning.
With this combination, you can significantly reduce the time between a problem occurring and your response to it.
Automating SSL Certificate Renewal
If you miss an SSL certificate renewal, your service will be blocked immediately. Use Nginx and Certbot to make this process a routine.
- Configure an Nginx reverse proxy to route HTTPS requests to port 443.
- Apply a post-hook script that reloads the Nginx configuration upon a successful Certbot renewal.
- Use
logrotate to compress log files and automatically delete logs older than 14 days to free up disk space.
By following this procedure, you can prevent the absurd accident of your site going down due to an expired certificate. Operations is the process of automating those tedious tasks one by one.