kysely-planetscale icon indicating copy to clipboard operation
kysely-planetscale copied to clipboard

Serverless driver performance

Open rcoundon opened this issue 1 year ago • 2 comments

I don't think this is an issue with this repo but wanted to ask this question here as you're likely to have experience. I did a small performance comparison with the standard MySQL connection and the new driver in a lambda function.

I found that when using the serverless driver the cold start times and the execution times in a warm lambda take at least twice as long, often longer. For example, for a cold start with MySQL it's 3-4s, with the HTTP driver, it's more like 10s. Warm starts are 1s compared to 3 or 4s

I haven't yet added any logging of what's taking the additional time, but before I dig into things further I was curious to find out what others' experiences were in terms of performance?

rcoundon avatar Oct 18 '22 08:10 rcoundon

From my end, I've been using the driver in Cloudflare Workers, so no particular cold start times there, everything is instant.

Having a whole 7 seconds of additional cold start time on Lambda is suspicious though, the serverless driver is essentially just a fancy wrapper around making network requests with fetch(), with no additional dependencies, so there may be something else at play that would contribute to what you're seeing.

It might be worth opening an issue in https://github.com/planetscale/database-js, they are more likely familiar with what might happen in Lambda.

jacobwgillespie avatar Oct 18 '22 13:10 jacobwgillespie

Thanks for getting back to me, I'll do that. It does seem very strange. If you don't mind, I'll report back here if anything comes out of it that could be useful

rcoundon avatar Oct 18 '22 13:10 rcoundon

I'm going to close this issue for now, as this library is just an adapter between @planetscale/database and kysely, so any performance issues should reside in one of those two libraries. But definitely feel free to post back if you discover anything, definitely interested to know what you find. 🙂

jacobwgillespie avatar Nov 05 '22 18:11 jacobwgillespie