Hướng dẫn mongodb multiple database connections - mongodb nhiều kết nối cơ sở dữ liệu

Bối cảnh: Tôi đang cố gắng tối ưu hóa tốc độ API Node.js của mình, được xây dựng với Express và Mongoose trên đám mây Amazon. Tôi có một cuộc gọi API mất nhiều thời gian để chạy [cuộc gọi API của tôi /số liệu thống kê biên dịch dữ liệu từ rất nhiều nguồn và do đó tạo ra hàng trăm truy vấn Mongo và do đó mất khoảng 20 giây để chạy]. Tôi đã nhận thấy rằng, trong khi cuộc gọi API này đang chạy, các cuộc gọi API khác cũng nhấn vào bộ bản sao Mongo đang chậm lại. Suy nghĩ đầu tiên của tôi là các truy vấn thống kê chậm, do đó chặn, nhưng theo bảng thống kê của tôi, tôi không có bất kỳ truy vấn nào mất> 100ms để chạy, và các số liệu thống kê DB Mongo của tôi đều ở trong phạm vi khá lành mạnh [hơn 20 truy vấn mỗi lần thứ hai,: I'm trying to optimize the speed of my Node.js API, built with Express and Mongoose on the Amazon Cloud. I have one API call that takes a good amount of time to run [my /stats API call compiles data from lots of sources, and thus makes hundreds of mongo queries and thus takes about 20 seconds to run]. I have noticed that, while this API call is running, other API calls that also hit the Mongo replica set are slow to return. My first thought was that the stats queries were slow, thus blocking, but according to my stat panel I don't have any queries taking > 100ms to run, and also my Mongo DB stats are all in pretty healthy ranges [20+ queries per second, : I'm trying to optimize the speed of my Node.js API, built with Express and Mongoose on the Amazon Cloud. I have one API call that takes a good amount of time to run [my /stats API call compiles data from lots of sources, and thus makes hundreds of mongo queries and thus takes about 20 seconds to run]. I have noticed that, while this API call is running, other API calls that also hit the Mongo replica set are slow to return. My first thought was that the stats queries were slow, thus blocking, but according to my stat panel I don't have any queries taking > 100ms to run, and also my Mongo DB stats are all in pretty healthy ranges [20+ queries per second,

Bài Viết Liên Quan

Chủ Đề