Requirements:
- Reliable / production-ready that wouldn’t break down randomly.
- Had a CLI to quickly deploy my FastAPI.
- A free tier so my clients can use the app free of charge to test out their idea fully, and only if they want to expand, they go to a higher plan / fixed plan, as my preference was to know exactly what to pay.
- Not have to put my card.
- Don’t need a Docker file or GitHub repo to deploy.
When I came to know about Vercel, I literally jumped with happiness because it was so easy to deploy. It had a free tier and fixed pricing per user, so cost was predictable, and it was production-ready. I was so happy about it...
...Until today. I was trying to add New Relic to my app, and I was very familiar with the lifecycle state and startup-shutdown event. So, I thought that I should initiate my relic in startup where I will also open my database connection and close the relic and DB in shutdown. Until then, I had been testing in localhost, but I thought, okay, it works on localhost, let’s see if it works on Vercel too because until this point, I was only hitting FastAPI endpoints and getting data, and it was working flawlessly. It was until I tried using the lifecycle state that I came to realize that Vercel does not trigger startup and shutdown, nor does it trigger middleware. The two things necessary for handling big apps were gone.
Vercel deployed my app as a serverless function, and every time I hit the endpoint, it would spin up the app, which is why those two things weren’t working. I found this problem 5 hours ago.
And I still haven’t found a solution. I honestly feel so demotivated. I wrote in FastAPI Reddit, and I got to know about:
- Render (discarded because it required a card).
- Flyio (discarded because it required a card).
- Koyeb (requires GitHub repo).
- And many others.
Is there any deployment that fulfills all my requirements above and also works with FastAPI lifecycle state and middlewares?