Wednesday, May 31, 2006

PHP, Mysql, Apache Performance tunning

Every project has one and more prominient requirement that it must give better performance to its end users and that shows projects/products quality.
I studied few things by my experience that is required for making project quality better. These are following:
  • Dedicated server: To make use of CPU 100% for that project it must have a fully dedicated sever.
  • High end server (Hardware must be equivalent to server level) Minimum of 2GB RAM, 3GHz Processor
  • SCSI Hard Drive (Faster than normal drive) - It is required if same server having database
  • APACHE CONFIGURATION: (Change httpd.conf - apache configuration file)
- KeepAlive On (whether or not to allow persistent connections)
- KeepAliveTimeout should be very low (this is the no of seconds to wait for next request for the same client) By keeping it very low it will remove connections with the client who has just send one request and next request from the same client will come after a long time so processor will not maintain a connection for a incosistent user. (for dynamic sites it must be low up to 5 second).
- No of processes apache can handle set to MaxClients (How many sub processes can a client generate) - It must be low also.
- StartServers must be low (If MaxClients is more than StartServers must be more). StartServer is the initial number of server processes to start, according to this number server generates processes at the time of booting the system. suppose that this no is 2 then at first server will generate 2 process and then wait for few seconds then again 4 then 8 and so on.
- MinSpareServers must be low. (minimum number of server processes which are kept spare) These are the child processes (which are called more) can be kept ideally so that further it can be called directly.
- MaxSpareServers must be low. (maximum number of server processes which are kept spare).
- MaxRequestPerChild (maximum number of requests a server process serves) - this is by default 0 but it should be set to something else. This number can be choosen by hit and trial method only.
- There is a scaling method to set the values for MaxClients ( RAM / (Average apache process size) ) = MaxClients
- For a site to be run with a very good performance , all apache server performance depends on these few points settings:
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0

  • Dual Apache Server: For Dynamic content one page takes a lot of time to load the whole page because it loads static data as well as dynamic content (images) - So to solve this problem you can use one more apache server on the same machine to process dynalic content seperately so that process of page could be make faster.
  • PHP Tunning: Php can handle performance only to a level. PHP provide a very good data handling technique, but only few developers are known with it. PHP support - _SERVER["HTTP_ACCEPT_ENCODING"] gzip,deflate
You have to make few changes in your php.ini file (php configuration file).
set output_handler = ob_gzhandler
This gzip will make HTML code in to a compressed format and this compressed data can be send to end user using less bandwidth.


Sunday, May 28, 2006

7 Awesome tools for PHP developers

For making programming better for PHP developers I came to know about few tools and resources. I am decribing here:
1. Framework: Frameworks provide a base for developping applications quickly. They provide intelligence to use most commonly used functions.
two commopnly used frameworks:
  • Symfony (www.symfony-project.com)
  • Zend Framework (http://framework.zend.com)
2. Compilers: PHP is a compiled language and it compiles code in to byte code and processed by the zend engine. The mod_php module does this job.
There are other compilers available that allow PHP to be compiled into other languages.
  • .Net (http://www.php-compiler.net/)
  • Java (http://www.caucho.com/resin3.0/php/)
  • Mono (http://php4mono.sourceforge.net/)
  • RoadSend PHP compiler - It converts PHP code into a standalone executable file with out the need of PHP on the target machine (http://www.roadsend.com)
  • www.priadoBlender.com
3. IDEs: To write PHP code some developers prefer vi or kate (linux developers).
There are some intresting one:
  • PHPEclipse (www.phpeclipse.net)
It provides PHP support to Eclipse and is really well done for peojects and debugging.

4. Debugging: Currently people uses echo or print/printf .
There are more efficient ways
  • Xdebug (www.xdebug.org) - Provides detailed stack trace and file/function information.
  • APD (Advanced PHP Debugger) - http://pear.php.net/apd/ - It can log porofile information in to a file that can later be analysed.
  • PhpEclipse also used for debugging.
5. Performance: to optimise applications.
  • alternative php cache (APC)- http://pear.php.net/apc/ - This is a good tool to analyse sluggish code points.
  • Database queries should be optimized.
  • memchached (http://www.danga.com/memcached/) - this is a daemon that caches objects in memory & optimises databbase performance.
6. Database:
  • Mysql query browser
  • To give a refreshing interface to your customer, to manage Mysql on the server use - phpFlashMyAdmin (http://www.tufat.com/s-flash-phpmyadmin.htm)
7. User Interaction (User Interface):
Dojo toolkit (http://dojotoolkit.org) - It provides excellent set of DHTML/AJAX widgets that you can easily integrate in your application.

Friday, May 26, 2006

Back after a long time ...

Since a long time was not getting time to blog.
Last week I celebrated my vacations with my parents and family, roamed around with mom dad and brother as well as met with my maami ji.
It was very exciting to meet them after a long time. Even I was counting from the starting of vacations now 7 days left now 6 now 5 .... to go back.
My God at last 1. :(
But I missed tekriti a lot.
Now today is my code freeze of this week so working late. We always try to finish it till evening but always due to any reason we become late.
People Aggregator is also too awating. And enjoying working late also.
Link