CPU usage peaks

Status
Not open for further replies.

jjth0196

New Member
Messages
6
Reaction score
0
Points
1
Hi everyone,
it's been a long time since I started using x10hosting and my website now as an average of 200 visitors a day.

This is great, however, I must now watch my CPU usage wich grew exponentially.

My script must do 5 requests (PHP : fsockopen) per visitor to a website and fetch the results.
It is a very CPU-consumming script, I rewrote from scratch my whole code to make it as simple as possible, and to use the less bandwidth possible.
I average a 200 realtime usage per hour (it used 400 before).
I also deleted all the contents of my website except the script.

My problem is : At some time in the day (from 03:00 to 05:00), and every day, I get a CPU usage peak.
There are no infinite loops anywhere in the code nor php errors logged.

I just don't understand why I have these CPU usage peaks, any ideas?

I can post the code if anyone want.

Thanks in advance,
Jjth

PS : I apologize for any errors I could have made in my post, I'm not english, if you don't understand anything just ask and I'll try to explain what I meant.
PS2 : see attachments :
 

Attachments

  • Sans titre.png
    Sans titre.png
    42.9 KB · Views: 38
  • Sans titre2.png
    Sans titre2.png
    32.6 KB · Views: 27

cybrax

Community Advocate
Community Support
Messages
764
Reaction score
27
Points
0
Without seeing the script it is hard to say, grabbing data from another site
in real time in response to a visitors request IS a nightmare to get right and five
fsock calls per visitor does seem excessive.

However visits between 03:00 to 05:00 could be the Googlebot indexing the site, looking at
the raw access logs will reveal the UserAgent of each visitor and you should be able to see them.
 
Last edited:

jjth0196

New Member
Messages
6
Reaction score
0
Points
1
Thanks for your answer, if you want I can send you the script by PM or just post it here but, since I rewrote it from scratch, I didn't add any comments (I know the mechanics of the script by heart) and it is insanely bad coded, but it is the fastest I came up with.

Actually I can't do anything about the 5 fsocks because, I need to retrieve a captcha image, and a cookie.
But you can't retrieve the image by itself.
You have to do this :
1. Request page 1 => Get cookies of page 1.
2. Request page 2 using cookies from page 1 => Get cookies from page 2.
3. Request page 3 with cookies from page 2 (It doesn't work if I don't request this one, it's the remote website's mechanics that want this)
4. Request captcha image with cookies from page 2 => User solve it and enters the different parameters he wants
5. Send the user's parameters + cookies from page 2+ the solved captcha & retrieve the response => Input valid or invalid
(6. Additional step if input is invalid => Request error page to know why the input is invalid)

It's a bit complicated but it is this only way to make things work, I tried every other possibilities.


Looking at raw logs is a good idea, but I don't know where to find them on x10hosting I searched on cPanel & on the ftp and couldn't find anything.
 
Status
Not open for further replies.
Top