Welcome Guest, Not a member yet? Register   Sign In
initial response time is too slow
#1

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
Reply
#2

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#3

(12-26-2020, 08:14 AM)includebeer Wrote: 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.
I am using cpanel to host
Reply
#4

@refay,
It would help if you could supply a link and access details.
Reply
#5

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#6

(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
Reply
#7

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?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#8

(12-28-2020, 05:19 AM)includebeer Wrote: 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?
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...
the file placed outside codeigniter passed all 5000 without any issues and the same test with codeigniter for a simple api request didn't even pass 100 request at a time most of them either timed out/internal server error
Reply
#9

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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
Reply
#10

(12-29-2020, 03:10 PM)includebeer Wrote: 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.
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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB