-5

I have a high performance PHP script that uses threads and perform a lot of HTTP Post and Database operation per each iterations. I won't dive into the script code here, caus it's a simple one, so there's no need to do so.

I want a server only to run this PHP script and nothing else, so I want all the possible server resources to be available for this script.

The issue:

I've tried to run this script in a server (it was tested in servers very similar to mine and it did a great job) with default configuration and I've achieved a bad performance (few iterations per second). And the script process just used 5% of CPU and 13% of memory. So, there should be some common bottlenecks, but I have no idea on what and how to avoid them.

As I never set up a server for cases like this before, could anyone please tell me where to begin with it? How would be a common server setup for me?

Edit:

Just got it! (can't answer my onw question... check my comment bellow) :D

cawecoy
  • 273
  • 3
  • 11
  • possible duplicate of [Server optimization for long running script](http://serverfault.com/questions/520945/server-optimization-for-long-running-script) – Daniel Widrick Jul 06 '13 at 05:24
  • It isn't reasonable to assess the performance of any running program without knowing what it does. There could be as many reasons you find it slow as things a computer can do. I suggest this is probably why you are stuck. – Falcon Momot Jul 06 '13 at 17:56
  • I know what it does. I actually don't know what its consequences to be so slow. Is it so hard to make sure all the server resource will be available to that script? – cawecoy Jul 08 '13 at 03:58

1 Answers1

1

Sounds like:

1) The script is not as optimized as you (and others) may think and like to claim (anecdotal evidence aside)

and

2) That you are IO locked either on the remote cURL calls or the hard drive (MySQL writes/reads)

.

Concerning things include:

Most OpenVZ hosts are not built to provide the max resources they advertise. Your host is probably over selling server resources which is compounding your issues. You should look at a different VPS Host Technology, (VMWare, Hyper V, KVM). If you truly NEED maximum performance, I would Look at getting a dedicated server with a SSD (or more in raid), and potentially a move from MySQL to Oracle (but that is a debate for another day).

All in all, Your best bet is a cheap a Dedicated server with:

  1. A high CPU Clock speed (3.0GHz or better)
  2. 1024 MB of RAM Minimum (Depending on how the script operates, throwing more memory at MySQL for caching may provide exponential results)
  3. An upstream internet connection with sufficient dedicated bandwidth for the cURL calls.

It's quite possible that your OpenVZ Host is IO locked on the HDD. Gaining access to even a dedicated sata drive could net you a 5-7x performance boost.

Also I assume this is a repost: Server optimization for long running script

Daniel Widrick
  • 3,488
  • 2
  • 13
  • 27
  • If so, it only can be an I/O lock. But it's weird... when I run X more instances of my script, I get X more work done. Can I fix that by configuring something properly (like MySQL config)? – cawecoy Jul 06 '13 at 04:41
  • If what you say is true, then we are back to the original:Your script is not optimized. It could potentially run faster if it was properly parrelleized. You may as well go find the dev or a forum centric to the script you are running. Without details we'll be unable to help. If you are getting the additional performance with additional instances, it means that MySQL is not the issue, neither is I/O locking in the truest sense. It is just that your script is running sequentially and blocking at some point. – Daniel Widrick Jul 06 '13 at 05:01
  • Well, I just saw an instance of this script doing 20 times more work than mine. Are you sure could it not about resource limits?! – cawecoy Jul 06 '13 at 05:12
  • Without any idea of what the script is / does, then no. You will have to provide the name of the script (if it is publicly available), or go find help from an 'enthusiasts'(people that are familiar with your mysterious script) group in tuning your server. – Daniel Widrick Jul 06 '13 at 05:22
  • Man, it is a simple one. This is not a place to dive into code (that's why there is the stackoverflow). I am here to discuss about server. Think in my misterious script like a "for()" in which each iteration has one HTTP Post and some database operations. I just gave information enough about it, it uses thread, and in many servers very similar to my VPS it does 20 times more iterations than mine does in a second. I am sure it's a server issue. All right, this discussion is not helping me nor anyone else who could have the same issue. So, I am done here. Thanks. – cawecoy Jul 06 '13 at 17:21
  • I successfully got to set up a nice server to suit my needs. I've got a VPS that perform a better req/sec (Linode). I also increase the PHP memory_limit and increase some mysql limits conf. With all this settings now I get a so much better performance. – cawecoy Jul 09 '13 at 13:28