Last active
August 29, 2015 14:03
-
-
Save reshadman/b3b0c1b9f3327966af98 to your computer and use it in GitHub Desktop.
بنچمارک کیو پیش فرض لاراول
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Machine: | |
Core i3 CPU 3Ghz | |
RAM 6GB | |
Hard Disk , SataII ~7000 rpm | |
Logic: | |
Laravel has queue:work in daemon and non-daemon mode, the non-daemon mode takes a job from Queue processes it and then the framework is shut down. | |
Test logic relies on multi processing + async request using non-daemon mode, | |
I used http://supervisord.org/ as process mangaer for making me able to run multiple "queue:work" at once and restart them one by one when they are shut down. I did some try & error and made two Superviserd processes which each run 40 "queue:work" and then restart them one by one when they are shut down. | |
In my machine I used "sleep(10)" instead of making real requests because of the lack of internet connection speed ( if I used my local machine for request backends It would effect the performance ) I considered that each request may tak 1-5 secs , when we are sending them in async mode the whole process for sending multiple requests takes 10 seconds and multipled by a safety factor we consider it 25 seconds , I pushed 1200 jobs to queue with the following code and above logic: | |
https://gist.github.com/bigsinoos/2c4207c8b559e5a9b35a | |
The above caused ~90% CPU Usage eternally (We have 80 queue:work process at once) | |
The test results are: | |
1200 times "queue:work" were run ( Number of our pushes) in 144 seconds an average of 8 run per second. | |
In each run we waited 10 seconds to mock that we can send 25 async requests in this time. so we have mocked 1200 * 25 = 30000 request in 144 seconds which means 208 requests per sec. | |
I also wrote an async code with the following to test in real mode and the result satisfied me with maximum possible connections based on my Internet speed ( about 3 request per sec): | |
https://gist.github.com/bigsinoos/5b109bc3c26ce372276b | |
The advantages of queue:work instead of queue:work --daemon is that the daemon mode is not really daemon it is shut down when it eats the memory limit (Behzad: the reason that we couldn't reach more than ~38000 jobs). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment