/    Sign up×
Community /Pin to ProfileBookmark

Server slowing down…

Hello!

Im currently running a php script that gets about 100 requests from internet users every second. The script is simple and only adds very little data to the mysql db.
The script only uses one INSERT command inserting only one bit to the DB and is very simple.

But its slowing down the server dramatically… Does anyone know how a problem like this can be solved?

I was thinking editing apache httpd.conf maybe?? But im new to running server alone so I need all the help I can get.

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 07.2006 — 100 requests per second = 100 new rows in the database per second?

So, after 10 hours you've added 3,600,000 rows to your database table???

I'm not sure what the overhead is for each row, but it's going to be quite a bit more than 1 bit. Other than looking at upgrading the hardware solution (faster server, more servers, faster disks, etc.), you can look at http://dev.mysql.com/doc/refman/5.0/en/optimization.html for lots of info on MySQL optimization.
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — 100 rows per sec yes, sometimes more... but the informstion is handled by another script that sorts later on. So the info is deleted after 2-3 minutes.

The server is used as an information collection unit but i know it can do mush better then this... problem is, im new to treeking ?
Copy linkTweet thisAlerts:
@acorbelliFeb 07.2006 — So you have two scripts running 100+ queries per second each? One to add, the other to sort?
Copy linkTweet thisAlerts:
@NogDogFeb 07.2006 — You might want to try using mysql_pconnect() instead of mysql_connect(), but read http://www.php.net/manual/en/features.persistent-connections.php first for the various issues to consider.
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — No, the second script is on a nother server so its not delaying the server at all at this moment.

The script thats delaying is using a

mysql_connect

and a query similar to

INSERT INTO table (col) VALUES ('1')...

technically this should not delay the server.... (i think...). So there has to be something else i need to tweek?
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — mysql_pconnect() is dangerous! after 2 min I get "Error, to many connections to server"
Copy linkTweet thisAlerts:
@acorbelliFeb 07.2006 — But is the second script accessing the database on the same server? My advice would be to make sure your script is cleaning up properly after itself, and only disconnecting from and reconnecting to the database when you need to.
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — okay, dont know any good cleaning functions ?

Do I need to clean after an Insert?

I noticed something strange. Comenting out all the connect and query functions the server lag continued!

It stoped when i removed <?php ?> completly from the page!... How can this be??
Copy linkTweet thisAlerts:
@SheldonFeb 07.2006 — Wow, What site is this that receives 100 hits/per second?

By cleaning i am assuming you mean removing the old data.

essentally your DB is getting 200 hits/per second, By working the 2 functions onto one server running as one would speed the process up.

But your last post suggests that the php script running the queries or around it has errors.

Post that code and maybe we can see what is giving you the errors.
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — OMG!

Just by adding:

<?php ?>

to the page will slow down the server dramatically! Its eating the CPU and there is no code....???!!! I found this on 2 different servers with 2 different setups of PHP!

How can this be?
Copy linkTweet thisAlerts:
@NogDogFeb 07.2006 — OMG!

Just by adding:

<?php ?>

to the page will slow down the server dramatically! Its eating the CPU and there is no code....???!!! I found this on 2 different servers with 2 different setups of PHP!

How can this be?[/QUOTE]

Can you find out if PHP was installed as an Apache module (SAPI mode) or as a CGI install? If it was installed in CGI mode, then every script run has to launch its own instance of PHP, whereas in module mode Apache launches it once and then keeps it running.
Copy linkTweet thisAlerts:
@deepauthorFeb 07.2006 — Im running it on Gentoo Linux, so I used

# emerge apache



to install (im not 100% sure but i think its modular)
×

Success!

Help @deep spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...