Author Topic: Server performance (2011)  (Read 891 times)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Server performance (2011)
« on: September 29, 2011, 09:14:26 AM »
I think we should make a new discussion about the server performance, similar to this one
http://community.bbgamezone.net/coding-discussion/resource-usage-db-vs-php/ but adjusted to the modern hardware capabilities.

There are 3 possible bootlenecks:
- CPU
- memory
- I/O

Coming from 2 possible sources:
- PHP (or any other scripting language, I will type PHP because it is only 3 letters :D)
- SQL database


My hypothesis is that IO might be the most important thing. Nowadays memory is really aboundant, I used to run 1000 daily players with 64MB (using LXadmin), the most resource consuming CPanel works well with 256MB, and the cheapest VPS plan usually have 512MB. CPU is not shabby either, everyone run on 4-8 cores and usually the server load is like 0.30 for me. So... the IO seems the most critical. And I suspect the sudden CPU spikes I sometimes experience might be actually caused by IO starvation...

Offline MrMaxx

  • Level 3
  • *
  • Posts: 8
  • Reputation: +0/-0
    • View Profile
Re: Server performance (2011)
« Reply #1 on: September 29, 2011, 03:26:26 PM »
Hmm...whats the bottleneck...the question is now do you scale...with very reasonable prices for dedicated server rents I would scale horizontally :)

First thing you do are the obvious ones...css-sprites, js-minification, compression...getting your requestcount and -size down.--because IO counts.
Until you get to the point where you store your static content into some CDN...so only your calls on dynamic resources remain.
Then you will optimize your code and implement caching where it makes sense.

After that you normally get a dedicated DB Server.
Then its horizontal scaling of your app-servers, leaving you with inconsisten local caches...no Problem if you use memcached....or you implement your own cohenrency protocol. And you need a sticky Loadbalancer too...

The question is...will you ever get to the point where you need more than one machine? But if you get there, you will probably have enough users to afford these extra pieces of hardware :D

Just my 2ct...
MrMaxx


Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: Server performance (2011)
« Reply #2 on: September 30, 2011, 08:17:42 PM »
IO,IO,IO, oh yeah and IO. It's plain and simple, everything will eventually fall to you waiting on your disks to spin so that you can process your data. Most PHP performance issues deal with the speed of your disks until you're at the scale of facebook and even then the speedup improvement compared to compiled code is negligible when compared with the speedup increase when moving to faster disks. Also I consider caching disk data in RAM is the same thing as IO since you're usingn it as a ramdisk or something similar. Fast data access is the key to all performance.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Server performance (2011)
« Reply #3 on: October 01, 2011, 11:23:11 AM »
First, the IO being the bottleneck is just a hypothesis, don't take it for granted. Let's evaluate it. Is it true or not?


JS, CSS, images - No, these can't affect IO. Most of them will be cached since the user already visited the page (we are talking here purely about browser games).

"Most PHP performance issues deal with the speed of your disks" - Again, impossible. PHP 5+ comes with eAccelerator, so all scripts are tokenized and cached, it does not even access any hard drive to read PHP script, it's all in memory.

It seems that IO bottleneck can be caused only by SQL.

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Server performance (2011)
« Reply #4 on: October 10, 2011, 10:52:56 AM »
you can optimize your webpage with the FF Plugin "YSlow"

http://developer.yahoo.com/performance/rules.html

there are Some Rules Actually this Forum has Grade B (A is Best)

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Server performance (2011)
« Reply #5 on: October 10, 2011, 11:05:28 AM »
you can optimize your webpage with the FF Plugin "YSlow"

http://developer.yahoo.com/performance/rules.html

there are Some Rules Actually this Forum has Grade B (A is Best)
Again, Yslow affects only CSS and images, these are cached most of the time in a browser game. It is irrelevant.
(if you ever encounter server performance problems due to images/css reads then way before that the bandwidth/network connectivity would become the bottleneck)

Offline BlackScorp

  • Level 15
  • *
  • Posts: 123
  • Reputation: +6/-0
    • View Profile
    • Cruel Online
Re: Server performance (2011)
« Reply #6 on: October 11, 2011, 02:59:55 AM »
my Boss told that the biggest Bottleneck on Webapps are MYSQL Queries. Which need much of ressources. So its better not to use stuffs like this:

SELECT * FROM table1 t1,table2 t2
WHERE t1.id = t2.id

or somethink like
$ids = array(1,2,3,4);

foreach($ids as $id){
SELECT * FROM table1 WHERE id = $id
}

i already crashed Several Times the Apache Server only because my SQL Queries wasnt Perfomant. So i gues if you use Perfomant Queries you will be fine with your server.

Also a Bottleneck could be Sending HTML Code over Ajax. I saw some games which used complete HTML Code as Ajax Return. Better is to send JSON array and parse the HTML DOM on Client side.

BTW as far as i know Browser doesnt Cache images everytime only if you add Expire Dates to the Images, else the Browser forget about your images if you close the browser. the same on JS and CSS Scripts.

Offline arai

  • Level 6
  • *
  • Posts: 22
  • Reputation: +1/-0
    • View Profile
Re: Server performance (2011)
« Reply #7 on: December 16, 2011, 06:17:38 PM »
Not to be a party pooper, but have you guys actually profiled your code to see where the actual bottlenecks are?  I've found that the biggest bottlenecks are in places where programmers didn't optimize, either because they didn't know how, or they were off following a hunch about something much less critical.

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,217
  • Reputation: +28/-1
    • View Profile
Re: Server performance (2011)
« Reply #8 on: December 17, 2011, 06:40:36 AM »
Not to be a party pooper, but have you guys actually profiled your code to see where the actual bottlenecks are?  I've found that the biggest bottlenecks are in places where programmers didn't optimize, either because they didn't know how, or they were off following a hunch about something much less critical.
It's impossible for indie devs like us :(
For example I have 6 types of games (+5 if you count freezed development and abandoned), these frequently come in more than one game instance, so I have like 20 games under direct or indirect supervision (which means that at the very least I have to assign and supervise the highest level staff there). I code everything alone. I work 8-12 hours a day and that's my physical limit :D Imagine me profiling all these games one by one? :)

We have no choice, we have to rely on supersitions and theories and feelings and what others think. Big companies can throw a programmer or even two who do nothing but optimize their product, we simply can't...

Offline Harkins

  • Level 28
  • **
  • Posts: 424
  • Reputation: +11/-2
  • Coder, blogger, entrepreneur.
    • View Profile
    • Push CX - Blog
Re: Server performance (2011)
« Reply #9 on: December 17, 2011, 06:03:02 PM »
http://www.NewRelic.com can make a huge difference - you drop their plugin into to your code and their website will track performance and highlight problems. It doesn't give you more hours in the day, but it means you spend a hell of a lot less time wondering where problems might be.

Visit #bbg on irc.freenode.net to talk browser games anytime.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal