jeremydaly / serverless-mysql

A module for managing MySQL connections at SERVERLESS scale
MIT License
1.2k stars 82 forks source link

Performance results #45

Open chainhead opened 5 years ago

chainhead commented 5 years ago

@jeremydaly great project! Do you have some benchmark reports that show a before-and-after comparison?

jeremydaly commented 5 years ago

Hi @chainhead,

I'm sure I do, but I'll need to dig for them. It would be a great independent side project to run some performance tests. I'd be happy to include anyone's results if they want to share.

Jeremy

trademark18 commented 3 years ago

@jeremydaly Can you shed some informal light on the performance of this package vs. the Data API? In my tests (which are not terribly scientific) it seems like the Data API may be a little bit slower than I hoped, maybe due to overhead. Would this be more performant, generally speaking?

jeremydaly commented 3 years ago

Hi @trademark18! This package is typically more performant than the Data API, but it requires a more complex environment setup (e.g. VPC, security groups, etc.). This library uses the mysql or mysql2 package behind the scenes, so the protocol is super fast as opposed to the HTTP-based Data API. The choice comes down to what your requirements are. Hope that helps.

trademark18 commented 3 years ago

@jeremydaly Thanks for the quick response. I suspected this was the case. I think the complexity would will be there anyway for this project, so I may give this a go for the performance gain. I have up to millions of Lambdas invocations per day, so keeping them quick saves $$!

I suppose we can assume that the connection management efficiency is roughly equivalent between Data API and serverless-mysql. I guess that would be the only other consideration.

By the way, thanks for the excellent blog posts and research on Aurora Serverless! I'm considering a migration from MSSQL on RDS and these resources have been most helpful.

canhnht commented 2 years ago

Hi @jeremydaly, I'm encountering an issue in performance. I'm using serverless-mysql and knex-serverless-mysql. I'm running MySQL Aurora instance. Before using serverless-mysql, my database has 1 primary and 1 reader replica. Since using serverless-mysql, I noticed a few things:

After removing serverless-mysql and adding back RDS proxy, the above issues are resolved:

When implementing serverless-mysql, my lambda functions is async function and end by calling context.done(). I also added context.callbackWaitsForEmptyEventLoop = false;.

Is there something wrong with my implementation of serverless-mysql? Or it's a problem in serverless-mysql? Thanks a lot!

canhnht commented 2 years ago

Hi @jeremydaly, can you take a look at this issue? I really want to replace RDS proxy by serverless-mysql, so that the cost can be reduced. But it seems like serverless-mysql is not helping. Thanks in advance.

Markkos89 commented 2 years ago

Hi @chainhead @canhnht, I believe that this issues you guys are having is related to cold starts and, thank god, Jeremy wrote about this in an article in his own page, to give some of his own insight, experience, and thoughts about cold starts, it's really a great article to read and I personally recommend it.

The great thing is that later, a few months after that post, he wrote another great article (I also recommend to read) with a proper solution for cold starts issues, wich ended up in a new npm package he also created, called lambda-warmer.

I hope this is related to your issues and hopefully the links will help you guys.

I'm about to try it in a PoC i'm building.

Lastly, a big thanks to you, @jeremydaly!