Tuesday, January 20, 2009

NIC Interrupts on Multi-Core

I wonder how many people out there have this issue and don't even know it. Let me explain what happening and how you would detect the problem and then suggest some ways to go about fixing it.

The easiest way to go about seeing if you have the problem is to cat the /proc/interrupts file.


[blog@web ~]$ cat /proc/interrupts
CPU0 CPU1 CPU2 CPU3
0: 165886477 0 0 0 IO-APIC-edge timer
1: 3 0 0 0 IO-APIC-edge i8042
8: 0 0 0 0 IO-APIC-edge rtc
9: 0 0 0 0 IO-APIC-level acpi
12: 4 0 0 0 IO-APIC-edge i8042
50: 0 0 0 0 IO-APIC-level sata_nv
58: 0 0 0 0 IO-APIC-level sata_nv
82: 210 0 0 107566 PCI-MSI eth0
90: 49 0 100834 0 PCI-MSI eth1




So you are asking now what are you to be looking for, well check out the eth0 and eth1 lines. As you can see this is a 4 Core box and has all the interrupts for eth0 running on CPU3 and eth1 on CPU2. This box is not in production so the numbers are small but still shows a problem. Following post will suggest fixes to this problem and the fix that I took.

Tuesday, January 13, 2009

7 Steps Of Scaling

I'm sure by now everyone has seen this but I should have it here as a reference.

7-stages-of-scaling-web-applications

By John Engales CTO, Rackspace. Good presentation of the stages a typical successful website goes through:
* Stage 1 - The Beginning: Simple architecture, low complexity. no redundancy. Firewall, load balancer, a pair of web servers, database server, and internal storage.
* Stage 2 - More of the same, just bigger.
* Stage 3 - The Pain Begins: publicity hits. Use reverse proxy, cache static content, load balancers, more databases, re-coding.
* Stage 4 - The Pain Intensifies: caching with memcached, writes overload and replication takes too long, start database partitioning, shared storage makes sense for content, significant re-architecting for DB.
* Stage 5 - This Really Hurts!: rethink entire application, partition on geography user ID, etc, create user clusters, using hashing scheme for locating which user belongs to which cluster.
* Stage 6 - Getting a little less painful: scalable application and database architecture, acceptable performance, starting to add ne features again, optimizing some code, still growing but manageable.
* Stage 7 - Entering the unknown: where are the remaining bottlenecks (power, space, bandwidth, CDN, firewall, load balancer, storage, people, process, database), all eggs in one basked (single datacenter, single instance of data).

Monday, January 12, 2009

PHP print vs echo

This is a big topic for anyone writing PHP so I thought I would do my own test. I ran each 3 times ignoring the first run. With this simple test it would seams that The Data follows.

PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies


Print
$i = 0;
for($i;$i<10000000;$i++)
{
print "Hello World.\n";
}
[blog@HomeWorkstation tmp]$ time ./print.php > /dev/null

real 0m5.894s
user 0m3.095s
sys 0m2.787s
[blog@HomeWorkstation tmp]$ time ./print.php > /dev/null

real 0m5.946s
user 0m2.943s
sys 0m2.996s
[blog@HomeWorkstation tmp]$ time ./print.php > /dev/null

real 0m5.838s
user 0m3.155s
sys 0m2.666s


Echo
$i = 0;
for($i;$i<10000000;$i++)
{
echo "Hello World.\n";
}

[blog@HomeWorkstation tmp]$ time ./echo.php > /dev/null

real 0m6.387s
user 0m3.150s
sys 0m3.208s
[blog@HomeWorkstation tmp]$ time ./echo.php > /dev/null

real 0m6.038s
user 0m3.091s
sys 0m2.928s
[blog@HomeWorkstation tmp]$ time ./echo.php > /dev/null

real 0m6.466s
user 0m3.330s
sys 0m3.110s

There are many pages out there at talk about this topic so do your own search or write your own code and let me know the results you find and I'll post them.

Here's another person's opinion.

http://www.faqts.com/knowledge_base/view.phtml/aid/1/fid/40

Friday, January 9, 2009

XSL Cache Anyone

So here a project put out by the Old Media people for all of us New Media people. If you are using the XSL functions in php you could see a 2.5x boost in performance. I have yet to try this package but if you have any benchmarking results you would like to share email them to me and I'll include them into this post.

XSL Cache

Thursday, January 8, 2009

Call For Topics

So for the first post I would like to make a call for topics. Why might you ask, well it will help me with getting this blog started. There are many topics that can be covered everything from power usage to using echo vs. print statements in php. I am planing to post twice a week if time allows. Help me get this blog rolling.

Email me at blog@scaletheblog.com