Tuesday, June 30, 2009

Nginx with FastCgi

Haven't been playing with linux web server for a while, I tried Nginx and it seems to be impressively fast:

Red Hat / CentOS Install nginx PHP5 FastCGI Webserver

How do I install and configure a ngnix FastCGI php5 HTTP / web server under Red Hat / RHEL / Fedora / CentOS Linux?

Nginx (engine x) is an HTTP(S) server, reverse proxy and IMAP/POP3 proxy server written by Igor Sysoev. It is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.
Step # 1: Enable EPEL repo

ngnix is not included in the base system. Turn on EPEL repo to install nginx stable release:
# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/$(uname -m)/epel-release-5-3.noarch.rpm
Step # 2: Install ngnix

Type the following command at a shell prompt:
# yum install nginx
Sample output:

Loaded plugins: downloadonly, fastestmirror, priorities, protectbase
Loading mirror speeds from cached hostfile
* epel: archive.linux.duke.edu
* base: ftp.linux.ncsu.edu
* updates: centos.mirror.nac.net
* addons: mirror.cs.vt.edu
* extras: centos.mirror.nac.net
0 packages excluded due to repository protections
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 0:0.6.34-1.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
Package Arch Version Repository Size
==============================================================================================================================================================
Installing:
nginx x86_64 0.6.34-1.el5 epel 319 k

Transaction Summary
==============================================================================================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total size: 319 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : nginx [1/1]

Installed: nginx.x86_64 0:0.6.34-1.el5
Complete!

nginx configuration file

* Default config file: /etc/nginx/nginx.conf
* Default SSL config file: /etc/nginx/conf.d/ssl.conf
* Default virtual hosting config file: /etc/nginx/conf.d/virtual.conf
* Default documentroot: /usr/share/nginx/html

Configure PHP As FastCGI

Type the following to install php5 with other modules:
# yum install php-pear-Net-Socket php-pear php-common php-gd php-devel php php-mbstring php-pear-Mail php-cli php-imap php-snmp php-pdo php-xml php-pear-Auth-SASL php-ldap php-pear-Net-SMTP php-mysql
Install spawn-fcgi simple program for spawning FastCGI processes

Type the following command:
# yum install spawn-fcgi
Next, download spawn-fcgi init.d shell script:
# wget http://bash.cyberciti.biz/dl/419.sh.zip
# unzip 419.sh.zip
# mv 419.sh /etc/init.d/php_cgi
# chmod +x /etc/init.d/php_cgi
Start php app server, enter:
# /etc/init.d/php_cgi start
# netstat -tulpn | grep :9000
Sample output:

tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14294/php-cgi

By default php server listens on 127.0.0.1:9000 port. Finally, update /etc/nginx/nginx.conf as follows:
# vi /etc/nginx/nginx.conf
Modify / append as follows:


location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}


Save and close the file. Restart nginx:
# service nginx restart
Create /usr/share/nginx/html/test.php as follows:


phpinfo();
?>

Original Post at http://www.cyberciti.biz/faq/rhel-fedora-install-configure-nginx-php5/

Sunday, June 28, 2009

Tip: Fighting OS-Level Fragmentation

SQL Server Magazine UPDATE TIP OF THE WEEK
This SQL Server tip is brought to you by SQL Server Magazine, the smart guide to building world-class applications! Click here for two free sample issues:

Tip: Fighting OS-Level Fragmentation
by Brian Moran

Q. I've read about how fragmentation at the SQL Server level can hurt my queries' performance. I understand how to look for fragmentation within my SQL Server tables by using the DBCC SHOWCONTIG command. However, should I also worry about fragmentation at the OS level?

A. Fragmentation exists at both the SQL Server level and the file level within the OS. It sounds like you already use DBCC SHOWCONTIG to combat SQL Server-level fragmentation (for a DBCC SHOWCONTIG primer, see SQL Server Books Online—BOL). So, let's look at how and when OS-level defragmentation can speed up your SQL Server.

Remember that SQL Server can report 0 percent fragmentation even when the on-disk files are horribly fragmented. SQL Server doesn't know or need to know how the OS physically lays out the bits on disk; it's the OS's job to manage physical bits on disk. However, because SQL Server doesn't know how the bits are laid out on disk, SQL Server has no direct way to report about file fragmentation. Imagine you're performing a table scan and SQL Server reports 0 percent fragmentation but the file that contains the table is scattered all over your disk. In this case, performing an OS-level defragmentation could help performance by making the files more contiguous on disk. However, defragmenting at the OS level doesn't always have the effect that you might expect. SQL Server pre-allocates space when you create a file. For example, if you create a 100MB file on a disk that's been defragmented recently, SQL Server creates the file in contiguous space. And SQL Server can read and write to that file forever, and the file won't fragment at an OS level (unless you stop SQL Server and perform a file-copy operation that puts the file into noncontiguous space). But if you create that 100MB file on a disk that's heavily fragmented, the file will also be fragmented.

What happens if SQL Server creates the 100MB file in contiguous space, but auto-grow operations increase the size of the file to 200MB? In this case, the new space added to the SQL Server file might fragment as the file grows. An OS-level defragmentation will improve performance if the files become fragmented and you're performing table-scan operations within SQL Server that look at ranges of data. So, I suggest scheduling a regular OS-level defragmentation. Given that file defragmentation is integrated in the operating system, defragmenting open files is perfectly safe. However, I/O activity generated must be considered if continuous high performance is mandatory. SQL Server slow time might not be a problem for small shops, but larger enterprise shops trying to maintain 4 or 5 nines (99.99% to 99.999%) of availability will be hard-pressed to find time for I/O intensive OS-level defragmentation. In such cases, many third-party defragmenters have advanced features to minimize or eliminate the I/O overhead of disk defragmentation. The best practice for highly available SQL Servers is to create your files on contiguous space that's already been defragmented, planning ahead of time for data growth and building that growth into the size of the initial files.

Send your technical questions to Brian Moran.


Additional Reference:
Microsoft SQL Server 2000 Index Defragmentation Best Practices
http://technet.microsoft.com/en-us/library/cc966523.aspx

Sunday, June 21, 2009

Factors influencing affective commitment

Factors influencing affective commitment

(Meyer & Tropoloynsky)

 

Ø  participation in decision-making

Ø  receptiveness to employees’ideas

Ø  discretion over activities

Ø  task autonomy

Ø  role clarity & freedom from conflict

Ø  positive feedback

Ø  job scope, job challenge

Ø  supportive leadership

Ø  transactional &transformational leadership

Ø  training & mentoring opportunities

Ø  performance-contingent rewards

Ø  job security

Ø  opportunities for growth & development

 

High Commitment” HRM

Ø  move from control-based management practices to those based on commitment

Ø  policies that promote mutuality

Ø  mutual goals, influence, mutual respect, rewards, responsibility

Ø  reduction in management hierarchy and division of labour, teamwork, manager as facilitator (less hands-on supervision)

Ø  According to Walton, policies of mutuality will elicit greater commitment

Ø  for successful work organisation, consider factors influencing job satisfaction, productivity & quality of work, innovation

 

 

Drivers of engagementInstitute of Employment Studies

 

Ø  Involvement in decision making

Ø  Freedom to voice ideas

Ø  Feeling enabled to perform well

Ø  Having opportunities to develop on the job

Ø  Feeling the organisation is concerned for the employees’health & well-being

 

Importance of line managers and front-line supervisors

 

Above is a slide I took from a management course which inspired me a lot in how an individual employee can be motivated and be fully engaged in the organisation and his/her job.


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

Wednesday, June 10, 2009

Comparing Table Variables with Temporary Tables


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________