My Express REST API is using Mongoose with MongoDB Atlas. Atlas is running an M10s (EC2 T2 smalls) and my REST API is on an EC2 M5 Large. I'm currently using the mongoose connection option "poolSize" as the default of 5 (so I think 15 total open connections to the replica set).

My Express REST API使用Mongoose和MongoDB Atlas。 Atlas正在运行M10(EC2 T2小型),我的REST API在EC2 M5 Large上运行。我目前正在使用mongoose连接选项“poolSize”作为默认值5(所以我认为15个完全打开的连接到副本集)。

I want my application to be able to handle 1000 requests/second to the Atlas DB.

我希望我的应用程序能够处理1000个请求/秒的Atlas数据库。

The DB is just a basic collection of 50K users with a couple data points on each as well as a 10kb profile image. 500 of the requests will be for the profile image and the other half for things like username and password auth.

数据库只是50K用户的基本集合,每个用户都有几个数据点以及10kb的配置文件图像。 500个请求将用于配置文件图像,另一半用于用户名和密码auth。

My MongoDB Atlas replica set says it has a max of 350 connections. If I am only utilizing 15 of those am I unintentionally creating a bottleneck here? Will those 15 connections (5/node) be able to handle 1000 requests per second? Should I increase my "poolSize" in Mongoose to 100 (300 total connections to replica set) in order to allow more requests per second? I realize the easy answer is to say go test it out, but first I wanted to hear roughly what I should do in this situation and know if my current setup of a "poolSize" of 5 will probably be fine for 1000 requests/s?

我的MongoDB Atlas副本集说它最多有350个连接。如果我只使用其中的15个,我会无意中在这里造成瓶颈?那15个连接(5个/节点)能够每秒处理1000个请求吗?我应该将Mongoose中的“poolSize”增加到100(与副本集的总连接数为300),以便每秒允许更多请求吗?我意识到简单的答案就是说要测试一下,但首先我想大致听到在这种情况下我应该做些什么,并且知道我目前设置的5“poolSize”是否可能适用于1000个请求/ s?

2 个解决方案

#1


7

I think this link here should help you: https://dzone.com/articles/how-to-use-mongodb-connection-pooling-on-aws-lambd

我认为这里的链接可以帮助您:https://dzone.com/articles/how-to-use-mongodb-connection-pooling-on-aws-lambd

One chunk of useful info from there:

那里有一大堆有用的信息:

The connection pool size determines the maximum number of parallel requests that your driver can handle at a given time. If the connection pool limit is reached, any new requests will be made to wait until the existing ones are completed. Hence, the pool size needs to be chosen carefully, considering the application load and concurrency to be achieved.

连接池大小确定驱动程序在给定时间可以处理的最大并行请求数。如果达到连接池限制,则将使任何新请求等到现有请求完成。因此,考虑到要实现的应用程序负载和并发性,需要仔细选择池大小。

Typically a low pool size will result in a lot of your requests sitting and waiting for a connection and might result in timeouts in high load.

通常,较低的池大小将导致您的大量请求等待连接,并可能导致高负载超时。

Go ahead and use JMeter or another tool set up to do concurrent requests to your app and see what kind of requests-per-second you are getting with the default 5 poolSize.

继续使用JMeter或其他工具设置来对您的应用程序执行并发请求,并查看使用默认的5 poolSize获得的每秒请求数。

Make sure to configure JMeter (or other tool) so that it have a realistic number of concurrent users and realistic requests that mirror what you will see in production is much as possible. And set up a few varieties like low-load, medium-load and high-load situations.

确保配置JMeter(或其他工具),使其具有实际数量的并发用户和实际请求,以反映您将在生产中看到的内容尽可能多。并设置了一些品种,如低负荷,中负荷和高负荷情况。

Once you have your baseline with the default settings, now you can increase the pool and see how the RPS responds.

使用默认设置获得基线后,现在可以增加池并查看RPS如何响应。

Also: watch out for memory consumption with large pool sizes, they eat up ~1megabyte per connection.

另外:注意大池大小的内存消耗,每个连接吃掉大约1兆字节。

This sort of empirical analysis is typically how you can get comfortable with your settings.

这种实证分析通常是您如何适应您的设置。

更多相关文章

  1. 制作一个基本的angularjs应用程序对我不起作用,我也不知道为什么
  2. Emberjs应用程序加载除Index之外的所有路由
  3. 在Android上使用离子崩溃而不是ios构建的混合应用程序
  4. 没有'Access-Control-Allow-Origin'反应表达docker应用程序
  5. 如何测试从实时网站提取数据的AJAX应用程序?
  6. 如何在单击按钮时将桌面应用程序导航到系统中设置的默认邮件提供
  7. Angular 2快速入门 - 我的应用程序组件未加载
  8. 如何访问远程节点。浏览器中的js应用程序,而不是本地主机
  9. 如果外部应用程序更改了持久模型(服务器数据库),AngularJS可以自

随机推荐

  1. c++中string类的常用方法有哪些
  2. C++ 引用和指针区别
  3. C语言比较三个数大小
  4. c语言实现输出所有的水仙花数
  5. xcode怎么使用
  6. %ld 在 C 语言中什么意思?
  7. c语言打印九九乘法表
  8. c语言中stract函数的意思
  9. C 语言中 fun 函数怎么用?
  10. c语言计算阶乘累加和