Pages

How to improve performace of a Website ?


Evaluation of website is an important step in any performance aspect. Its level of aspect varies from application to application, based on a variety of factors (such as application at code level, architecture and databases). It has been an issue to pass judgment on the performance hurts either on database level or in application layer for many years. Here, I’m trying to focus on both levels.

Application Layer
Followings are some practices in my opinion through which we can improve the performance of web at application level.
  • Select only required column
Don't query columns that you don't need in your application. We use entire table fields in most of the case by using active records.
  • Avoid Group By, Distinct , Not In
These will create temporary tables on database which is major performance headache; these can be handling on application layer via server side scripting.
  • Data Types
While creating a query at application, I have noticed many times, data types which are expected are not provided, Like When an integer is expected, it’s given under apostrophes’.  Data type length and type must be provided accurately.
  • LIMIT
When Getting a Unique Row use limit. This way the database engine will stop scanning for records after it finds just 1, instead of going through the whole table or index.
  • Fixed-length (Static) Tables
These are faster; it can be apply by replacing VARCHAR, TEXT, BLOB.

Database Layer
Followings are some highlighted issues for improvement.
  • indexes
 Apply on primary key which are used on joins, frequently in search criteria and Used as foreign key fields. It will significantly improve the performance especially on big tables like practitioners.
  • Default Values
Set default value rather than Null. Null means missing unknown value. It cannot use the arithmetic comparison operators such as =, .
  • Use short primary keys
I’ve noticed, long keys are used on many times of length 11 digits, which is avoidable.
  • Appropriate Data Types
Use integer field more as you can instead of string and varchar instead of text type.
  • Use of Mysql functions
Avoid Mysql costly functions on queries; these can be handled on application layer.
  • Correlated queries
Correlated queries also create temporary tables these can be handle by dividing the query into two queries, execute inner query as a separated request and provided the result to outer query via server side scripting.

Other Experiments which can enhance performance
  • Persistent connections
Application of persistent connections on cross database scheme if its required
  • skip-locking
It will improve SELECTs but has an overhead of INSERT/UPDATES.
  • Partitioning
Partitioning would be helpful for big tables


Please add your comments if you have more suggestions.

My PHP V5.4 RC7 Build test results


NOTE: I tested PHP V5.4 with following environment:
Operating System: Ubuntu 10.10
Processor: Intel Pentium Dual CPU 2GHz
RAM: 4 GB
System Type: 32-bit

======================================

 TIME END 2012-01-30 07:47:23

======================================
RESULT SUMMARY
---------------------------------------------------------------------
Exts skipped    :   51
Exts tested     :   26
---------------------------------------------------------------------


Number of tests : 12007              8117
Tests skipped   : 3890 ( 32.4%) --------
Tests warned    :    0 (  0.0%) (  0.0%)
Tests failed    :   24 (  0.2%) (  0.3%)
Expected fail   :   36 (  0.3%) (  0.4%)
Tests passed    : 8057 ( 67.1%) ( 99.3%)
---------------------------------------------------------------------
Time taken      : 2692 seconds
======================================


======================================
FAILED TEST SUMMARY
---------------------------------------------------------------------
Test open_basedir configuration [tests/security/open_basedir_linkinfo.phpt]  XFAIL REASON: BUG: open_basedir cannot delete symlink to prohibited file. See also bugs 48111 and 52176.Inconsistencies when accessing protected members [Zend/tests/access_modifiers_008.phpt]  XFAIL REASON: Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2Inconsistencies when accessing protected members - 2 [Zend/tests/access_modifiers_009.phpt]  XFAIL REASON: Discussion: http://marc.info/?l=php-internals&m=120221184420957&w=2Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770.phpt]  XFAIL REASON: See Bug #48770Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_2.phpt]  XFAIL REASON: See Bug #48770Bug #48770 (call_user_func_array() fails to call parent from inheriting class) [Zend/tests/bug48770_3.phpt]  XFAIL REASON: See Bug #48770Initial value of static var in method depends on the include time of the class definition [Zend/tests/method_static_var.phpt]  XFAIL REASON: Maybe not a bugDateTime::add() -- fall type2 type3 [ext/date/tests/DateTime_add-fall-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::add() -- fall type3 type2 [ext/date/tests/DateTime_add-fall-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::add() -- fall type3 type3 [ext/date/tests/DateTime_add-fall-type3-type3.phpt]  XFAIL REASON: Various bugs existDateTime::add() -- spring type2 type3 [ext/date/tests/DateTime_add-spring-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::add() -- spring type3 type2 [ext/date/tests/DateTime_add-spring-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::add() -- spring type3 type3 [ext/date/tests/DateTime_add-spring-type3-type3.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- fall type2 type3 [ext/date/tests/DateTime_diff-fall-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- fall type3 type2 [ext/date/tests/DateTime_diff-fall-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- fall type3 type3 [ext/date/tests/DateTime_diff-fall-type3-type3.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- spring type2 type3 [ext/date/tests/DateTime_diff-spring-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- spring type3 type2 [ext/date/tests/DateTime_diff-spring-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::diff() -- spring type3 type3 [ext/date/tests/DateTime_diff-spring-type3-type3.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- fall type2 type3 [ext/date/tests/DateTime_sub-fall-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- fall type3 type2 [ext/date/tests/DateTime_sub-fall-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- fall type3 type3 [ext/date/tests/DateTime_sub-fall-type3-type3.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- spring type2 type3 [ext/date/tests/DateTime_sub-spring-type2-type3.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- spring type3 type2 [ext/date/tests/DateTime_sub-spring-type3-type2.phpt]  XFAIL REASON: Various bugs existDateTime::sub() -- spring type3 type3 [ext/date/tests/DateTime_sub-spring-type3-type3.phpt]  XFAIL REASON: Various bugs existBug #52062 (large timestamps with DateTime::getTimestamp and DateTime::setTimestamp) (32 bit) [ext/date/tests/bug52062.phpt]  XFAIL REASON: Waiting for resolution of the 32-bit case.Bug #53437 (Crash when using unserialized DatePeriod instance) [ext/date/tests/bug53437.phpt]  XFAIL REASON: Bug #53437 Not fixed yetRFC: DateTime and Daylight Saving Time Transitions (zone type 3) [ext/date/tests/rfc-datetime_and_daylight_saving_time-type3.phpt]  XFAIL REASON: RFC not implemented yetBug #42718 (unsafe_raw filter not applied when configured as default filter) [ext/filter/tests/bug42718.phpt]  XFAIL REASON: FILTER_UNSAFE_RAW not applied when configured as default filter, even with flagsBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) [ext/session/tests/bug60634.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write during exec [ext/session/tests/bug60634_error_1.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write during exec [ext/session/tests/bug60634_error_2.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write after exec [ext/session/tests/bug60634_error_3.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write after exec [ext/session/tests/bug60634_error_4.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in close during exec [ext/session/tests/bug60634_error_5.phpt]  XFAIL REASON: Long term low priority bug, working on itBug #45712 (NaN/INF comparison) [ext/standard/tests/math/bug45712.phpt]  XFAIL REASON: Bug 45712 not fixed yet.
======================================


======================================
TEST SUMMARY
---------------------------------------------------------------------
version string [sapi/cli/tests/001.phpt]
strip comments and whitespace with -w [sapi/cli/tests/007.phpt]
execute a file with -f [sapi/cli/tests/008.phpt]
using invalid combinations of cmdline options [sapi/cli/tests/009.phpt]
syntax check [sapi/cli/tests/011.phpt]
invalid arguments and error messages [sapi/cli/tests/012.phpt]
syntax highlighting [sapi/cli/tests/014.phpt]
CLI long options [sapi/cli/tests/015.phpt]
basic function [sapi/cli/tests/php_cli_server_001.phpt]
$_SERVER variable [sapi/cli/tests/php_cli_server_002.phpt]
Bug #55726 (Changing the working directory makes router script inaccessible) [sapi/cli/tests/php_cli_server_003.phpt]
Bug #55747 (request headers missed in $_SERVER) [sapi/cli/tests/php_cli_server_004.phpt]
Post a file [sapi/cli/tests/php_cli_server_005.phpt]
Bug #55755 (SegFault when outputting header WWW-Authenticate) [sapi/cli/tests/php_cli_server_006.phpt]
Bug #55758 (Digest Authenticate missed in 5.4) [sapi/cli/tests/php_cli_server_007.phpt]
SERVER_PROTOCOL header availability [sapi/cli/tests/php_cli_server_008.phpt]
PATH_INFO (relevant to #60112) [sapi/cli/tests/php_cli_server_009.phpt]
Bug #60180 ($_SERVER["PHP_SELF"] incorrect) [sapi/cli/tests/php_cli_server_010.phpt]
Bug #60180 ($_SERVER["PHP_SELF"] incorrect) [sapi/cli/tests/php_cli_server_011.phpt]
Bug #60159 (Router returns false, but POST is not passed to requested resource) [sapi/cli/tests/php_cli_server_012.phpt]
No router, no script [sapi/cli/tests/php_cli_server_013.phpt]
Bug #60477: Segfault after two multipart/form-data POST requestes [sapi/cli/tests/php_cli_server_014.phpt]
Bug #60523 (PHP Errors are not reported in browsers using built-in SAPI) [sapi/cli/tests/php_cli_server_015.phpt]
Bug #60591 (Memory leak when access a non-exists file) [sapi/cli/tests/php_cli_server_016.phpt]
====================================

You may have found a problem in PHP.This report can be automatically sent to the PHP QA team athttp://qa.php.net/reports and http://news.php.net/php.qa.reportsThis gives us a better understanding of PHP's behavior.If you don't want to send the report immediately you can chooseoption "s" to save it. You can then email it to qa-reports@lists.php.net later.Do you want to send this report now? [Yns]: Y  

Please enter your email address.(Your address will be mangled so that it will not go out on anymailinglist in plain text): abc.abc@gmail.com

Posting to http://qa.php.net/buildtest-process.php

Thank you for helping to make PHP better.

Can I expect PHP-GTK V3.0 in 2012?


PHP is a widely-used general-purpose scripting language, GTK is a cross-platform widget toolkit for creating graphical user interfaces and PHP-GTK is a set of language bindings for PHP which allow GTK+ GUI applications to be written in PHP.



I have been working on PHP-GTK for some-time, but it seems that PHP-GTK applications crash easily, they are slow and are not according to desktop application expectations. Also I have found a lot of criticism regarding it, like:

"if you want to build a desktop application, you can't really do that well in PHP (sorry php-gtk). Then .NET would be a better choice."
Reference: http://linkd.in/yB75JH

"PHP-GTK is a real stretch of PHP's intended use. I'd personally stay away."
Reference: http://bit.ly/wzxrKe

"I agree with the answers there in that PHP is not a language designed for GUI applications and can heartily recommend Python+Qt."
Reference: http://bit.ly/wzgttJ

However, as Andrei Zmievski says "I firmly believe that PHP is a better project because of PHP-GTK."
Reference: http://bit.ly/AgBLlr

I think PHP V6.0 is coming out any-time soon, GTK+ V3.0 is already there. Is there any work going on for PHP-GTK Version 3.0? Can I expect PHP-GTK V3.0 in 2012?

I have asked this same question on StakOverFlow. You can answer my question over here:
http://stackoverflow.com/questions/8955053/can-i-expect-php-gtk-v3-0-in-2012

Popular Posts