initial response time is too slow |
Hi
I am new to CI and have used CI4 for REST api the problem i am facing is cold start the first request to the server takes atleast 3-5 seconds and subsequent requests if made within 5-10 seconds takes 400-700ms. And the issue repeats after no traffic for more than 10 secs. Is there some configurations i am missing
I don’t know what can cause this, but I don’t think it’s something you can fix in CI’s config. Probably something on your server.
Ask your hosting company, It can be a lot of things. Maybe the connection to MySQL is slow, maybe it waits for an apache process to start. It’s impossible to tell just like that. But I’m pretty sure it’s not a problem with CI’s config.
(12-27-2020, 07:52 AM)includebeer Wrote: Ask your hosting company, It can be a lot of things. Maybe the connection to MySQL is slow, maybe it waits for an apache process to start. It’s impossible to tell just like that. But I’m pretty sure it’s not a problem with CI’s config. even without sql operation the issue exist and dont think its a problem with server/hosting as i tested with a html file placed outside codeigniter folder and it seems to work fine
Do you use any cache system that would expire after 10 seconds?
Do you have any complicated SQL queries? Do you retrieve a lot of data that would explain the delay? (12-28-2020, 05:19 AM)includebeer Wrote: Do you use any cache system that would expire after 10 seconds?no cache system and for testing purpose i am just returning a hardcoded response theres no sql or any kind of heavy tasks and another thing i found when i did a load testing using apache bench Code: ab -k -n 5000 -c 50 https://myurl...
Ok then, what were the internal server error?
Also, is the file you placed outside CI was the same as the one inside CI? A controller with just an echo to test the performance should return in miliseconds, it’s really not normal to have a timeout. Check your log files to see if there’s some error messages, because with the info you gave so far, there’s no way to know what is happening. (12-29-2020, 03:10 PM)includebeer Wrote: Ok then, what were the internal server error?Yes both files are same file. And its throws timeout or 500 error when load testing and there is no logs/errors captured by CI. And when i test 1 api at a time through postman only the initial request takes time subsequent request works fine(CI startup issue??) Is there any memory restrictions set by CI? as i can see that even when load testing with 5000 requests my server ram/cpu usage is very low |
Welcome Guest, Not a member yet? Register Sign In |