0

The benefits of serverless computing are obvious yet when it needs connections to databases (for example sql server) usually when too many requests exist it may create bottlenecks and connection pool exhaustion.

What is the best solution for serveless computing while working with databases?

Carlos Alves Jorge
  • 1,919
  • 1
  • 13
  • 29
  • If it's leading to pool exhaustion, then you're doing it wrong. I've currently got multiple Azure Functions that performs thousands of requests per day just fine. – James Jan 30 '19 at 11:43
  • If you have 500 executions in one second will it not lead to your connection pool to exhaust? – Carlos Alves Jorge Jan 30 '19 at 11:49
  • it really boils down to a. what those DB requests are doing and b. if your DB is setup to handle 500 requests per second. For example, if each DB requests takes 10ms to execute then there's a very good chance (if 500 is the magic number) the DB simply isn't capable of handling that level of load e.g. in that scenario the DB could only handle ~100 requests per second. Point being, you'll probably find it's less about the fact you're using a Serverless function and more about the limitations of your DB. – James Jan 30 '19 at 12:03
  • That’s my point... the database isn’t scalable like the serverless architecture. Anyone with experience with serverless databases? – Carlos Alves Jorge Jan 30 '19 at 12:26
  • One of the approach is to front database with a caches like Redis. – Siri Jan 30 '19 at 12:34
  • @CarlosAlvesJorge apologies I may have misconstrued your question, I have no idea of what your DB setup looks like, however I can't really see past this being a case of not using the right tool for the job - have you perhaps considered moving to a more scalable DB designed for high-throughput e.g. [CosmosDB](https://azure.microsoft.com/en-us/services/cosmos-db/)? – James Jan 30 '19 at 13:29
  • Connection Pool exhaustion means that you are not reusing correctly your connections. SQL Server does this at the driver level if I remember correctly. Cosmos DB uses a client you can cache to reuse in-between executions. If Connection Pooling is the issue, you can take a look at https://github.com/Azure/azure-functions-host/wiki/Managing-Connections – Matias Quaranta Jan 30 '19 at 17:00

1 Answers1

0

A partial answer, specifically addressing Azure Functions:

  1. See the general connection management guidance.

  2. You can also tune your bindings in your function app's host.json file - for example, the HttpTrigger has maxOutstandingRequests and maxConcurrentRequests settings. If your database doesn't have the scaling capability of Functions - for example, if you're doing a partial or staged cloud migration and your database is still on-prem - these settings can limit your Functions traffic so it doesn't overwhelm your rate-limiting components.

Katy Shimizu
  • 1,051
  • 5
  • 9