Sending SMTP mail to gmail using PHP

Sending mail from your web server is a very common thing that many of us need to do. To do this, the most common approach is to use the following PHP code:

mail($to, $subject, $message, $headers);

This method sends a copy of the email, directly to the recipients mail server from the web server. However generally speaking, the web server is not the real mail server for the domain you’re trying to send from which can cause major issues.

For example, lets say I have a website at www.myweb.com and when someone registers it sends them an email from the address website@myweb.com. The recipients mail servers spam filtering facility may do an MX lookup on the myweb.com domain and notice that the real mail server for the myweb.com has a different IP address to the address where the email is originating from (the web servers IP address). For this reason web server emails are often flagged as spam and thus never received by the intended recipient.

To avoid this, we can relay the mail through the domains real mail server using SMTP. Using this method the mail will come to the recipients mail server from the real mail server for the senders domain as seen in its MX records. This then avoids the problematic spam filter rule.

To achieve this I use the Mail.php class as found in the PEAR::Mail library located at http://pear.php.net/package/Mail. If you’re using CentOS like me, you can easily install this package using the following command

#yum install php-pear-Mail

In this example I’m connecting to a gmail server which requires the connection to be over SSL:

 

<?php
require_once('Mail.php');
$host = 'ssl://smtp.gmail.com';
$port = '465';
$username = '<your email address>';
$password = '<yourPassword>';
$subject = 'my subject';
$to = '<to email address>';

$from = $username;
$message = 'test';
$headers = array ('From' => $from,
   'To' => $to,
   'Subject' => $subject);
$smtp = Mail::factory('smtp',
   array ('host' => $host,
     'port' =>; $port,
     'auth' => true,
     'username' => $username,
     'password' => $password));
$mail = $smtp->send($to, $headers, $message);
if (PEAR::isError($mail)) {
        echo('<p>'.$mail->getMessage().'</p>');
}
?>

If SSL wasn’t required I’d just need to remove the ‘ssl://’ from in front of the host declaration and change the port to 25 like this:

$host = 'mail.myweb.com';
$port = '25';

Obviously you’ll need to ensure that your firewall allows your web server to make connections to your smtp host over port 25 or 465 for SSL.

Posted in Development, Linux, Networking, PHP | Tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , | 2 Comments

Performance tuning a CentOS LAMP web server for high traffic volumes

In August 2010 I was contracted to performance tune a LAMP server to handle approximately 70 full page loads per second which equated to 4,250 concurrent virtual users. We ended up doubling this expectation to 140 full page loads per second without striking issue. If this speed was maintained for 24 hours it would equate to over 12 million hits per day. This article will let you know how we achieved it.

The load tests were conducted using the HP performance center; a technology that HP obtained as part of its acquisition of Mercury for approximately USD$4.5 billion in 2006.

To find out more about the load testing software visit http://en.wikipedia.org/wiki/HP_LoadRunner

Goal:
Handle 4,250 concurrent users generating approximately 70 full page loads per second.

1 full page load consisted of:
- 1 dynamically generated PHP file using MySQL
- 4 JavaScript files
- 7 CSS files
- 8 image files

Original starting environment:
- ServerModel: Dell R300
- RAM: 2GB (2 x 1GB chips)
- Operating System: CentOS release 5.5 (Final)
- Apache: v2.2.3 (running in prefork mode)
- MySQL: v5.0.77
- PHP: v5.1.6 (as an apache module)
- eAccelerator: v0.9.5.3
- 120Mbits of bandwidth

 

Round 1: Initial Test

Round 1: Configuration

At the start of the process we were pretty much using the default configurations for the entire lamp stack. Linux was running iptables and ip6tables in its default configuration. eAccelerator was operating with 32MB of memory with optimization and caching enabled.

Apache (/etc/httpd/conf/httpd.conf):
For more info on variables for Apache 2.0.x go to: http://httpd.apache.org/docs/2.0/mod/mpm_common.html

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

MySQL (/etc/my.cnf):
For more info on variables for MySQL 5.0.x go to: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

[mysqld]
max_connections = 100
max_user_connections = 0
max_connect_errors = 10
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 2M
read_buffer_size = 131072
read_rnd_buffer_size = 262144
myisam_sort_buffer_size = 8M
thread_cache_size = 0
query_cache_size= 0
thread_concurrency = 10

Round 1: Results

With these settings we got up to 30 page loads per second which was 42% of our target. Interestingly, we were only operating at about 8% CPU and about 50% of our memory capacity when we hit this limit.

Round 1: Review

Looking at the apache error logs we were getting a large number of MySQL errors:

mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in xxx.php on line 15

So the MySQL configuration seemed to be our bottleneck:

 

Round 2

Round 2: Configuration

We did our first major review of the Apache and MySQL performance settings and adjusted them accordingly. We doubled the Apache settings and used the ‘huge’ configuration as supplied with mysql (/usr/share/doc/mysql-server-5.0.77/my-huge.cnf).

Apache (/etc/httpd/conf/httpd.conf):
For more info on variables for Apache 2.0.x go to: http://httpd.apache.org/docs/2.0/mod/mpm_common.html

<IfModule prefork.c>
StartServers       16
MinSpareServers    10
MaxSpareServers   40
ServerLimit      512
MaxClients       512
MaxRequestsPerChild  8000
</IfModule>

MySQL (/etc/my.cnf):
For more info on variables for MySQL 5.0.x go to: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

[mysqld]
# Memory usage
skip-locking
max_connections = 500
max_user_connections = 500
max_connect_errors = 999999
key_buffer = 384M
max_allowed_packet = 1M
table_cache = 512
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size = 32M
# Try number of CPU's*2 for thread_concurrency (eHound has 4 CPU's)
thread_concurrency = 8

# Disable Federated by default
skip-federated

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

As an extra precaution we locked the network card in the server to use 1Gbit:

#ethtool -s eth0 speed 1000 duplex full

Edit the configuration for the network card:

#vim /etc/sysconfig/network-scripts/ifcfg-eth0

Add the following line:

ETHTOOL_OPTS='autoneg on speed 1000 duplex full'

Restart the network:

#service network restart

Round 2: Results

With these settings we got up to 58 full page loads per second which was 59% of our target. Interestingly, we were still only operating at about 10% CPU capacity when we hit this limit but we were using approximately 70-80% of our memory.

Our MySQL errors had disappeared and there were no more errors in the Apache logs.

Round 2: Review

We were concerned that the system was starting to use swap memory which was slowing the server to a halt.

 

Round 3

Round 3: Configuration

We added an additional 2GB of RAM to the server so it now contained 4 x 1GB chips.

Round 3: Results

With the new RAM we still only got up to 58 full page loads per second which was 59% of our target. We were still only operating at about 10% CPU capacity but now we were only using about 40% of our memory.

Round 3: Review

Still no errors in the Apache logs and the load test farm was not receiving Apache errors. In fact it was reporting that it could not even connect to the server. This led us to believe that it was either a lack of bandwidth or a NIC/network/firewall configuration issue. After checking with our datacenter, we found that there were no inhibiting factors that would cause the problem described.

We increased the Apache & MySQL Limits and ran a different style of test.

 

Round 4

Round 4: Configuration

In this test we only loaded the dynamic components of the page as generated by PHP and MySQL and served by Apache. This meant that we told the load test farm not to download static content such as images, CSS or JavaScript files.

Also we increased the MySQL and Apache limits as follows:

Apache (/etc/httpd/conf/httpd.conf):
For more info on variables for Apache 2.0.x go to: http://httpd.apache.org/docs/2.0/mod/mpm_common.html

<IfModule prefork.c>
StartServers     280
MinSpareServers   100
MaxSpareServers   300
ServerLimit      1536
MaxClients       1536
MaxRequestsPerChild  32000
</IfModule>

MySQL (/etc/my.cnf):
For more info on variables for MySQL 5.0.x go to: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

[mysqld]
# Memory usage
skip-locking
max_connections = 764
max_user_connections = 764
max_connect_errors = 999999
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency (eHound has 4 CPU's)
thread_concurrency = 8

# Disable Federated by default
skip-federated

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

Round 4: Results

The results of this test were very interesting. We got up to 263 page loads without any issue. This consumed a lot more bandwidth than test 3 so we knew that bandwidth was not the issue. However the number of connections that both tests started to fail at were very similar.

Round 4: Review

So we knew we had a connection limit issue.

We also knew that the eAccelerator optcode cache was not dying at these high volumes, nor was MySQL, PHP or Apache.

We reviewing the kernel messages and found thousands of the following messages that were logged at the time of testing:

#cat /var/log/messages* | grep 'Aug 15'
...
Aug 15 01:04:27 localhost kernel: printk: 1395 messages suppressed.
Aug 15 01:04:27 localhost kernel: ip_conntrack: table full, dropping packet.
Aug 15 01:04:32 localhost kernel: printk: 1561 messages suppressed.
Aug 15 01:04:32 localhost kernel: ip_conntrack: table full, dropping packet.
Aug 15 01:04:37 localhost kernel: printk: 1274 messages suppressed.
Aug 15 01:04:37 localhost kernel: ip_conntrack: table full, dropping packet.
Aug 15 01:04:42 localhost kernel: printk: 1412 messages suppressed.
...

Further investigation revealed that the iptables/ip6tables was activated and limiting the number of connections to the box because its table was full. Ordinarily when I set up a linux server I turn iptables off because I place hardware firewalls in front of the servers. However I didn’t have the opportunity to setup this box initially, so they were still activated. I however didn’t need them, so I deactivated them.

If you still need to keep iptables running you can simply adjust the following settings:
Check the current connections limit (only works if iptables is running):

#sysctl net.ipv4.netfilter.ip_conntrack_max
65536

Change the connections limit:

#vim /etc/sysctl.conf

Add the following lines:

# conntrack limits
#inet.ipv4.netfilter.ip_conntrack_max = 65536
net.ipv4.netfilter.ip_conntrack_max = 196608

Reload the config file:

#sysctl -p

Check the new connections limit:

#sysctl net.ipv4.netfilter.ip_conntrack_max
196608

Check the current buckets limit (only works if iptables is running):

#cat /proc/sys/net/ipv4/netfilter/ip_conntrack_buckets
8192

To change the buckets limit:

#vim /etc/modprobe.conf

Add the following lines:

options ip_conntrack hashsize=32768

Reboot the server:

#shutdown -r now

Check the new buckets limit:

#cat /proc/sys/net/ipv4/netfilter/ip_conntrack_buckets
24576


Alternatively if you don’t need iptables like me, you can just disable them:

#service iptables stop
#service ip6tables stop
#chkconfig iptables off
#chkconfig ip6tables off

 

Round 5

Round 5: Configuration

This test used exactly the same configuration with iptables disabled.

Round 5: Results

Success!!! We got to 4,250 concurrent users which is about 70 pages per second (loading all additional image, CSS and JavaScript files also) with zero errors and a 0.7 second average response time. This used about 120Mbits worth of bandwidth pipe. The datacenter ended up running out of pipe before the server had any issues.

At this rate we were running at about:
- 15% CPU utilisation
- 30% Memory usage (with 4GB RAM installed)
- 400 apache threads
- 100% Bandwidth

Round 5: Review

Key findings:
- Increase your Apache and MySQL limits
- Turn off iptables
- Ensure that you have enough RAM
- Ensure that you are checking logs from MySQL, Apache, and the kernel to pick up any errors and give you clues as to how to best solve them

 

Round 6

Round 6: Configuration

This test used exactly the same configuration as round 5 with 250Mbit pipe instead of a 120Mbit pipe.

Round 6: Results

Success!!! We got to 140 full page loads per second (including additional images, CSS and JavaScript files also) with zero errors and still a stable 0.7 second average response time. This used the full 250Mbits worth of bandwidth pipe. The datacenter ended up running out of pipe again before the server had any issues.

At this rate we were running at about:
- 30% CPU utilisation
- 40% Memory usage (with 4GB RAM installed)
- 800 apache threads
- 100% Bandwidth

Round 6: Review

Key findings:
- Even with 250Mbits of pipe, bandwidth is still the bottleneck in this configuration.

 

Round 7

Round 7: Configuration

Even though our server was performing fine, we were given another server to experiment on with much higher specs.

It was a Dell R710 with 48GB of RAM and 8 2.53MHz Xeon processors running in hyper-threading mode (essentially making 16 processors).

We also had this box connected to a dedicated 4Gbit optical internet feed to give it as much bandwidth as it needed.

Everything on the box was configured the same except for Apache and MySQL (which we took the last settings and multipled them by 4) and sysctl.

Apache (/etc/httpd/conf/httpd.conf):
For more info on variables for Apache 2.0.x go to: http://httpd.apache.org/docs/2.0/mod/mpm_common.html

<IfModule prefork.c>
StartServers     1120
MinSpareServers   400
MaxSpareServers   1200
ServerLimit      6144
MaxClients       6144
MaxRequestsPerChild  128000
</IfModule>

MySQL (/etc/my.cnf):
For more info on variables for MySQL 5.0.x go to: http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html

[mysqld]
# Memory usage
skip-locking
max_connections = 3056
max_user_connections = 3056
max_connect_errors = 999999
key_buffer = 1024M
max_allowed_packet = 4M
table_cache = 1024
sort_buffer_size = 4M
read_buffer_size = 4M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 256M
thread_cache_size = 32
query_cache_size= 64M
# Try number of CPU's*2 for thread_concurrency (eHound has 4 CPU's)
thread_concurrency = 32

# Disable Federated by default
skip-federated

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

[mysqldump]
quick
max_allowed_packet = 64M

[mysql]
no-auto-rehash

[isamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M

[mysqlhotcopy]
interactive-timeout

We also added the following lines to sysctl:
ip_conntrack_max = 196608
net.ipv4.ip_local_port_range = 1025 65535   
net.ipv4.tcp_max_tw_buckets = 1000000
net.core.somaxconn = 10000
net.ipv4.tcp_max_syn_backlog = 2000
net.ipv4.tcp_fin_timeout = 30

Round 7: Results

We got to 200 full page loads per second (including additional images, CSS and JavaScript files also) with zero errors and still a stable 0.8 second average response time. This test used 330Mbits or about 8% worth of the bandwidth available. We stopped the test simply because we didn’t need to go any higher, but potentially could have gone much higher.

At this rate we were running at about:
- 16% CPU utilisation
- 6% Memory usage (with 48GB RAM installed)
- 1227 apache threads
- 8% Bandwidth

Round 7: Review

Key findings:
- Bandwidth seem to be a much bigger bottleneck than server capability.

 

Summary

A Dell R300 with good specs can be acquired for about AUD$4,000-$4,500 and should handle over 2800 hits per second on a 20/1 dynamic/static file ratio or 140 full page loads per second in our case if it is configured correctly.

You don’t need a $25,000 server to get good performance, you just need to take some time to make sure that you are getting the most out of your hardware and ensure that your available bandwidth can handle the load you require.

Posted in Architecture, Linux, MySQL, Networking, Performance Tuning, PHP | Tagged , , , , , , , , , , , , , , , , | 5 Comments

Monitoring CentOS server performance using sar

Sar can be used to record a large number of server resource utilisation statistics in a binary log format which you can then analyse.

To install sar:

#yum install sysstat

To run sar and save the binary output to a file:

#sar -A -o /var/log/performanceTests/sarLog 5 0

sar parameters:
-A: records ALL server stats
-o: elects the binary output file Path
5 0: [interval count] in seconds: take stats every five seconds indefinitely

You can then use the sar tool to read and display the stats you require. I’ll be writing another article on how to do this soon.

Posted in Linux, Performance Tuning | Tagged , , , , , , , , | 2 Comments

Count lines of code in a linux web project

Go into your directory containing your web code:

#cd /var/www/html/myVirtualHost

Use the following command to count the lines of code in php, inc, js and css files:

#find . -type f -name '*.js' -o -name '*.css' -o -name '*.inc' -o -name '*.php'   | xargs wc -l | tail -n1
31065 total
Posted in Development, Linux, PHP | Tagged , , , , , , , , , , | Leave a comment

See how much RAM is installed on your CentOS server

To see how much RAM you have installed on your CentOS server, you can use the following commands:

#cat /proc/meminfo
MemTotal:      2069956 kB
MemFree:         60652 kB
Buffers:         16032 kB
Cached:        1831416 kB
SwapCached:         32 kB
Active:         172144 kB
Inactive:      1791604 kB
HighTotal:     1174144 kB
HighFree:         4008 kB
LowTotal:       895812 kB
LowFree:         56644 kB
SwapTotal:     4128760 kB
SwapFree:      4127320 kB
Dirty:             244 kB
Writeback:           0 kB
AnonPages:      116184 kB
Mapped:          26952 kB
Slab:            29148 kB
PageTables:       3424 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:   5163736 kB
Committed_AS:   477492 kB
VmallocTotal:   114680 kB
VmallocUsed:      5716 kB
VmallocChunk:   108740 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     4096 kB
#dmidecode --type 17 | grep Size
	Size: 1024 MB
	Size: 1024 MB
	Size: No Module Installed
	Size: No Module Installed
	Size: No Module Installed
	Size: No Module Installed
#free -m
             total       used       free     shared    buffers     cached
Mem:          2021       1948         73          0         21       1769
-/+ buffers/cache:        157       1864
Swap:         4031          1       4030

The server used in this example has 2GB of RAM in the form of 2 x 1GB chips.

Posted in Linux, Performance Tuning | Tagged , , , , , , , | Leave a comment

Enforcing Gigabit Ethernet on CentOS 5.x

To determine the current ethernet connection link speed you can use the following commands:

#dmesg | grep -i duplex
tg3: eth0: Link is up at 100 Mbps, full duplex.
#ethtool eth0
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Supports auto-negotiation: Yes
	Advertised link modes:  10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Advertised auto-negotiation: Yes
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: g
	Wake-on: d
	Current message level: 0x000000ff (255)
	Link detected: yes

To force the ethernet connection to Gigabit ethernet, edit your network settings:

#vim /etc/sysconfig/network-scripts/ifcfg-eth0

Add the following lines:

ETHTOOL_OPTS=&quot;autoneg on speed 1000 duplex full&quot;

Restart the network:

#service network restart

Once set run the following commands again to ensure that it worked:

#dmesg | grep -i duplex
tg3: eth0: Link is up at 1000 Mbps, full duplex.
#ethtool eth0
	Supported ports: [ TP ]
	Supported link modes:   10baseT/Half 10baseT/Full
	                        100baseT/Half 100baseT/Full
	                        1000baseT/Half 1000baseT/Full
	Supports auto-negotiation: Yes
	Advertised link modes:  1000baseT/Full
	Advertised auto-negotiation: Yes
	Speed: 1000Mb/s
	Duplex: Full
	Port: Twisted Pair
	PHYAD: 1
	Transceiver: internal
	Auto-negotiation: on
	Supports Wake-on: g
	Wake-on: d
	Current message level: 0x000000ff (255)
	Link detected: yes

To determine what sort of ethernet card (NIC) is in your server:

#lspci|grep Eth
01:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5722 Gigabit Ethernet PCI Express

To get statistics on your ethernet card (NIC):

#ethtool -S eth0
NIC statistics:
     rx_octets: 2759019776
     rx_fragments: 0
     rx_ucast_packets: 23966653
     rx_mcast_packets: 0
     rx_bcast_packets: 222
     rx_fcs_errors: 0
     rx_align_errors: 0
     rx_xon_pause_rcvd: 0
     rx_xoff_pause_rcvd: 0
     rx_mac_ctrl_rcvd: 0
     rx_xoff_entered: 0
     rx_frame_too_long_errors: 0
     rx_jabbers: 0
     rx_undersize_packets: 0
     rx_in_length_errors: 0
     rx_out_length_errors: 0
     rx_64_or_less_octet_packets: 0
     rx_65_to_127_octet_packets: 0
     rx_128_to_255_octet_packets: 0
     rx_256_to_511_octet_packets: 0
     rx_512_to_1023_octet_packets: 0
     rx_1024_to_1522_octet_packets: 0
     rx_1523_to_2047_octet_packets: 0
     rx_2048_to_4095_octet_packets: 0
     rx_4096_to_8191_octet_packets: 0
     rx_8192_to_9022_octet_packets: 0
     tx_octets: 31867950633
     tx_collisions: 0
     tx_xon_sent: 0
     tx_xoff_sent: 0
     tx_flow_control: 0
     tx_mac_errors: 0
     tx_single_collisions: 0
     tx_mult_collisions: 0
     tx_deferred: 0
     tx_excessive_collisions: 0
     tx_late_collisions: 0
     tx_collide_2times: 0
     tx_collide_3times: 0
     tx_collide_4times: 0
     tx_collide_5times: 0
     tx_collide_6times: 0
     tx_collide_7times: 0
     tx_collide_8times: 0
     tx_collide_9times: 0
     tx_collide_10times: 0
     tx_collide_11times: 0
     tx_collide_12times: 0
     tx_collide_13times: 0
     tx_collide_14times: 0
     tx_collide_15times: 0
     tx_ucast_packets: 32202050
     tx_mcast_packets: 6
     tx_bcast_packets: 5
     tx_carrier_sense_errors: 0
     tx_discards: 0
     tx_errors: 0
     dma_writeq_full: 0
     dma_write_prioq_full: 0
     rxbds_empty: 0
     rx_discards: 0
     rx_errors: 0
     rx_threshold_hit: 0
     dma_readq_full: 0
     dma_read_prioq_full: 0
     tx_comp_queue_full: 0
     ring_set_send_prod_index: 0
     ring_status_update: 0
     nic_irqs: 0
     nic_avoided_irqs: 0
     nic_tx_threshold_hit: 0
Posted in Linux, Networking, Performance Tuning | Tagged , , , , , , , | Leave a comment

Light Peak – One connector to rule them all

[tweetmeme source="wwjamieson3"]

Light Peak

Never before has inter-device communication been so prevalent in our day to day lives. Most of us have hard-drives, iPods, iPhones, digital video and still cameras, and a plethora of other devices all needing to connect to our computers. This often leaves our PCs looking like a long tentacled bionic octopus with various cables spewing out of it

ranging in both shape and size. What we really need is one type of connector that we can use for all our devices. Something that is standardised, fast and flexible enough to handle our device communications requirements for next decade.


Enter Light Peak; Intel‘s ground-breaking new high speed optical technology. Here’s how it works:

[Speed]
Light Peak can currently operate at sustained speeds of up to 10GB per second (thats an entire BluRay movie in less than 30 Seconds) in both directions simultaneously.  Furthermore, Intel believes that the technology can be refined to deliver speeds of up to 100GB per second over the next decade.

Don’t get me wrong, I love the wireless revolution as much as anybody.  But practically, as long as wireless remains a relatively slow communication technology, there will always be a need for high-performance cabled connections.

[Multiple Protocols]
There is freedom in standardisation. USB (Universal Serial Bus) was all always touted as the champion of cable standardisation but failed in its ability to deliver due to speed and flexibility limitations. Even USB 3.0 (not even released yet), is still very limited in speed (only 10 times speed of USB 2.0) and is likely to suffer limited vendor adoption.

Light Peak has the ability to run multiple protocols simultaneously over a single cable. This means that instead of having different connectors for Firewire, Sound, Ethernet, USB, SCSI, SATA, DVI, and HDMI, all our connections can run over a Light Peak cable. With light peak we could use the same cable to connect a monitor, hard drive or digital camera to our PC. Even more impressive is that the technology can do all this with support for hot-plugging.  There is also talk of Intel working on a copper carrying version of Light Peak so that it can be used for power cables.

[Size and Length]
Light Peak cables are thinner, more flexible and can stretch up to 30 metres (100 Feet). They also have tiny connectors which are perfect for small devices like laptops, phones and storage keys.


Rumours abound over Apple‘s Steve Jobs originally taking the technology to Intel‘s Paul Otellini to ask him to produce back it in 2007.   But the substantiation of such rumours holds little interest for consumers.

Intel demonstrated a working prototype of the technology on an Apple Mac at the 2009 Intel Developer Forum (IDF) and are expecting to ship the technology in 2010. The demonstration showcased a Mac Pro running two 1080p video streams, as well as LAN and storage devices over a single 30 metre (100 foot) long cable.  At this same forum, Intel also announced plans to introduce a smaller, low-power version of Light Peak for portable devices in 2011.

Sony are also a majors partners in the technology along with Apple, with both manufacturers planning to release Light Peak capable products in 2010.

Posted in Technology | Tagged , , , , , , , , , , , , | Leave a comment

Get run level on CentOS

To determine the current run level of a CentOS installation, use the following command:

/sbin/runlevel
Posted in Linux, Run Levels | Tagged , , , | Leave a comment

Mounting a new disk partition using CentOS

First, we need to create the directory that we want to mount the new partition to (otherwise known as the mounting point):

# mkdir /backups

Then we edit and add a line to /etc/fstab defining the parameters for the new mount:

# vim /etc/fstab

Add a line like the one below but customised for your own requirements:

# Device                Mount Point             FS      Options         D P
/dev/xvdc               /backups                ext3    defaults        1 2

Any new entries made to /etc/fstab will not auto-mount.  To mount these new partitions without having to reboot the server, use the following command:

# mount -a

To check that our new mount point is up and running, we can use the following command:

# mount
/dev/xvda on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/xvdc on /backups type ext3 (rw)

You can also use the following command to see its size:

# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda              12G  508M   12G   5% /
tmpfs                 361M     0  361M   0% /dev/shm
/dev/xvdc              20G  129M   19G   1% /backups
Posted in File Systems, Linux | Tagged , , , , , | Leave a comment