-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parse Server handles cloud code request sequentially #3696
Comments
nodejs/expressjs should process the request in 'parallel', but parallel is not the parallel you may think. nodejs being event driven, when a request arrives to the server, there is no guarantee that this request will be processed immediately, if the runloop is already busy processing another request. Given the amount of ram you have on your server, you can probably start with the cluster option (if using the CLI) Otherwise you can use PM2, which would be able to spawn multiple nodejs processes on your instance and allow for higher concurrency. Also, that seems odd that your functions take 20s to respond, did you check the indexes in the mongo database? |
Whenever there is a cloud code request that calls a database function a HTTP request is made from the server back to itself. The default path for this is on localhost so without clustering it will block other requests. You should check your mongo logs for slow queries first as suggested, but also clustering is a must when using cloud code. Even with clustering you can expect a very few requests to be stalled. You can also try enabling direct access which removes the HTTP request step. This can be done by setting the environment variable PARSE_SERVER_ENABLE_EXPERIMENTAL_DIRECT_ACCESS to 1. |
Below is the my code - Parse.Cloud.define("ping", function (req, res) { }); function sleep(time, callback) { When ping cloud function gets called then other cloud calls from any user gets stucked untill sleeps time complete. There is solution other than cluster to solve this problem. Without making any change in my code. |
The problem is your sleep method, you're blocking the whole event loop with your while. you should probably replace
by
|
Ok Fine, Now i just remove the sleep code, I am calling ping request from js sdk client at every 15 seconds its response time is showing sometimes more than 5 seconds , i have set condition on response if response not come in 5 seconds then show week signal. There is any method to improve the performance of parse server and reduced the response time of ping or any cloud request. |
I'm not sure what your 'LoginHelper.updateSessionUpdateTime' does but you should probably check what's in it and why it takes so much time. Before pinning 'on parse-server' the time it takes to respond, you can try to remove your custom code and see the baseline for such requests. you should be able to serve millions of requests per day with parse-server and respond well below 100ms. |
Below is my ping cloud code :- main.js //Ping request from client }); LoginHelper.js updateUserSessionEndDateTime: function (req, callback) { Now i am checking the performance of parse server with js client by sending 1000 ping request from client :- function ping() { My last ping request response comes in 55.65 sec. Why parse server is not handling the request very fast. |
I believe I answered a similar issue somewhere else |
Hi, I am using parse server on my stand alone server(rackspace) for my game. When calling cloud functions from its response time is high takes to much time, sometime it gives response in 20 sec. Currently only 4-5 users are playing.
Server Configuaration : Rackspace server, 4 GB RAM
DB Server : Mongo Atlas, 2GB RAM
When i am using sleep in my parse cloud code then call to my all cloud function gets stcuked. Its handling cloud code request sequentially. Can you please explain the steps to configure my parse server to handles cloud code request parallally.
I am writing client code of game in Unity and JS.
Thanks
The text was updated successfully, but these errors were encountered: