Simple server solution when serverless is not enough

I am building an app and I need to connect it to either BigQuery or ClickHouse. Fetching this data warehouses from Next js api folder seem to had connection overhead on every request which makes it slower and more expensive. Does Theo, or anyone else have a good solution for this? I guess the reasonable solution would be to have a server always running, what solution would you recomend for this? For context Connection Overhead: Serverless environments are designed to handle short-lived, stateless requests. They typically spin up instances on-demand and terminate them after the request is processed. If you connect to ClickHouse from a serverless function, each request would need to establish a new connection, incurring additional overhead. This could impact performance, especially if you have frequent or concurrent requests.
2 Replies
Eternal
Eternal13mo ago
Now I'm Theo, or even an intern. But if I had this problem and I was hell bent on keeping server less in there, Id have a server always running. Server less sends post request to that server, like you suggested yourself. One problem would be fear of someone finding that server on shodan or whatever. So use an auth header? Don't have to be complex. Idk, that's just my two cents.
Giacomo
Giacomo13mo ago
Yes, thanks for the suggestion! That is the solution I plan to go with. I will use a simple express server on Cloud Run. I just wanted to check whether I was missing any other optimal solution