Stress testing and profiling tools for web application

Hi there,

Recently I came across some cool new tools along with some of my old favorites and thought this calls for a quick post -

Front End Profiling Tool:

FireBug: Firebug is pretty handy to find out how long it is taking your website to load and render as well as how many header calls are made to fetch external java-script and css files. It also packs lots of useful tools and a must have for any serious web application developer.

YSlow:YSlow sort of gives your an easy to understand report on your web pages flaws and how to overcome them.

Web Server Stress Testing Tool:

Siege: Siege is a command line tool that you can install and simulate concurrent hits to any particular URL.

Example:

siege -c 10 -r 10 http://www.mydomain.com/

Above code pings the URL concurrently with 10 connections repeating 10 times making 100 hits to the URL.

MySQL database Profiling Tool:

Jet Profiler:Jet profiler Shows the real time activity of the connected mysql database once its hooked up. It is pretty useful when used together with the siege tool and see how concurrent hits affect the database.


Naturally these are not all that is out there so any new inputs from the readers will be most welcomed :)





thanks,

faisal ahmed

web application developer
web: http://www.faisalbd.com/
email: thephpx(at)gmail(dot)com

Share

Linux: Bash script for dynamic symbolic link creation

Hello everyone,

I just created this simple but useful bash script to create symbolic link. It lets me avoid going into my local server root located at /var/www/ and instead symbolic link of a folder located at /home/public/ is created at /var/www/ so anything that you put inside /home/public/project1 or project2 or whatever the folder name is it also gets reflected and thus can be accessed via link http://localhost/project1 or http://localhost/project2 and so on.

STEP 1: create a file named symlink at /home/public/ or anywhere you like. Then copy the following code inside it and save it.

  1. #! /bin/bash
  2. sudo mkdir -m 777 $1
  3. sudo ln -s /home/default/Public/$1 /var/www
  4. echo $1 symbolic link created


STEP 2: To use the script to create a folder and create a symbolic link at the server root located at /var/www/ you have to type in the following code and press enter.

  1. sh symlink faisal


On the above code sh is the prefix required to run the bash script named symlink and faisal is the name of the folder i want to create and link to /var/www/

Hope the above snippet was useful.



thanks,

faisal ahmed

web application developer
web: http://www.faisalbd.com/
email: thephpx(at)gmail(dot)com

Share

Dummies guide to LAMP setup on linux :)

Hello everyone,


Recently I came across several nifty apt-get commands that quite handy and if used properly can be a life saver while setting up LAMP stack on your system.


Step 1 : One line LAMP setup on linux -

  1. sudo apt-get install lamp-server^



Step 2 : Setup phpMyadmin to manage your mysql databases -

  1. sudo apt-get install phpmyadmin



Step 3 : Setup xdebug and integrate with php5 installation -

  1. sudo apt-get install php5-xdebug



Step 4 : Setup cURL -

  1. sudo apt-get install php5-curl



After the above command finishes installing curl do the following -

  1. cd /etc/php5/conf.d/
  2. sudo gedit xdebug.ini



After opening the file in gedit, add the following lines at the end of the file then save and close it.

  1. xdebug.remote_enable=On
  2. xdebug.remote_host="localhost"
  3. xdebug.remote_port=9000
  4. xdebug.remote_handler="dbgp"



The following step is helpful for those who later want to integrate andorid SDK, because only Sun JDK is supported when running the android SDK app, is handy if you use it.


Step 5 : Setup sun -

  1. sudo apt-get install sun-java6



Step 6 : Enable Rewrite Module for PHP -

  1. a2enmod rewrite





The above will do a smooth install of a functioning LAMP server on the system :D , comments and queries are always welcomed.


thanks,

faisal ahmed

web application developer
web: http://www.faisalbd.com/
email: thephpx(at)gmail(dot)com

Share

Codeigniter: Helper for template library dynamic view partial loading

Hello everyone,

I have recently been in quick-fire blogging mode. After playing with the superb template library developed by Phil Sturgeon.

The following template helper is the outcome of tweaking that makes life easier while setting up view partials and calling them inside the layout dynamically. The helper also has an add-on use which gives user the option to use region specific partial loading.

Controller:

welcome.php

$partial_list[]['region'] = 'left';
$partial_list[]['name'] = 'category';
$partial_list[]['view'] = 'partial_category';
$partial_list[]['region'] = 'right';
$partial_list[]['name'] = 'login_box';
$partial_list[]['view'] = 'partial_login';

/* following functionautomatically sets the partials
* based on the above array and also passes $partial_list
* variable to the view.
*/

/*
* make sure the pareser helper is loaded before
* calling this function
*/

setup_partials($partial_list);

$this->template->set_layout('home_layout');
$this->template->build('home_view');


Layout:

home_view.php

<html>
<head>
	<title><?php echo $template['title'];?></title>
</head>
<body>
	<div class="left">
		/* Will show only partials with region set as left */
		<?php show_partials('list', 'left', $partial_list, $template); ?>
	</div>
	<div class="mid"><?php echo $template['body'];?></div>
	<div class="right">
		/* Will show only partials with region set as right */
		<?php show_partials('list', 'right', $partial_list, $template);?>
	</div>
</body>
</html>

Detail about the usage can be found in the actual helper file, also feel free to comment here and I will try my best to help out.

Download Helper:

DOWNLOAD PARSER HELPER

thanks,

faisal ahmed

web application developer
web: http://www.faisalbd.com/
email: thephpx(at)gmail(dot)com

Share

Internet explorer compatibility test with expression web super preview

In the recent past I was involved in couple of UI development and cross browser integration and its during this time I came across “expression web super preview” , which comes from Microsoft for FREE :P

This application can be called an AIO (all in one) IE test suit in terms of UI consistency checks. It allows you to compare different version of the same site in 2 different version of the internet explorer side by side. It also has the option to view the site in various screen resolutions.

I felt it was too nice a product to be shared online and hope it remains free till something else comes up :) only downside is I can use it only on windows systems only.

To download the application click here.

thanks,

thephpx

Share

Staged Code-Igniter Web Application Development

Today I am going to share a little customization that I do while i develop codeigniter based web application. Now a days in most web application development firms a three-tire development process is followed. This is done to ensure smooth roll-out of the application from development to live.

The three-tire development methodology involves three stages of development servers. First comes the local server which is setup in your laptop or workstation. Then comes the internal test server, which is a central server that holds all the SVN repository as well as hosts the site and make it accessable to all from within the network. This server is also sometimes called staggin server. Last but not the least comes the live server, in most cases its your clients server where you upload your codes after they have passed the QA checks of both local-server and staging-server.

One related aspect of staged development is that in most cases they involve using SVN server for version control. Using SVN, though you can automatically update your server files from SVN server through “svn update” command but if the config file is not configured to take the different servers into consideration you will have to update the config file every time you do update on a server or set separate config file on each server and add the file to ignor list of the SVN repository.

Our way of doing it is to use a single config file and make it lookup the host address to determine which configuration settings to use.  If you are familiar with codeigniter then you already know you will find your config file at system/application/config/config.php.

Find the following line in the config.php file:

  1.  $config[‘base_url’] = "http://localhost/codeigniter/";

Replace the line with the following lines -

  1. if($_SERVER[‘HTTP_HOST’] == "localhost"){
  2.   $config[‘base_url’] = "http://localhost/codeigniter/";
  3. }else if($_SERVER[‘HTTP_HOST’] == "192.168.1.1"){
  4.   $config[‘base_url’] = "http://192.168.1.1/codeigniter/";
  5. }else{
  6.   $config[‘base_url’] = "http://www.live-server.com/codeigniter/";
  7. }

Now all your URL’s will be adjusted based on the server the site is accessed from. Next we will modify the database.php file which is also located in system/application/config/database.php

Find the following line(s) in the database.php file:

  1.  $db[‘default’][‘hostname’] = "localhost";
  2.   $db[‘default’][‘username’] = "root";
  3.   $db[‘default’][‘password’] = "";
  4.   $db[‘default’][‘database’] = "restobolivia";
  5.   $db[‘default’][‘dbdriver’] = "mysql";
  6.   $db[‘default’][‘dbprefix’] = "";
  7.   $db[‘default’][‘pconnect’] = TRUE;
  8.   $db[‘default’][‘db_debug’] = TRUE;
  9.   $db[‘default’][‘cache_on’] = FALSE;
  10.   $db[‘default’][‘cachedir’] = "";
  11.   $db[‘default’][‘char_set’] = "utf8";
  12.   $db[‘default’][‘dbcollat’] = "utf8_general_ci";

Replace the above line with the following once:

  1. if($_SERVER[‘HTTP_HOST’] == "localhost"){
  2.  
  3.   $db[‘default’][‘hostname’] = "localhost";
  4.   $db[‘default’][‘username’] = "root";
  5.   $db[‘default’][‘password’] = "password";
  6.   $db[‘default’][‘database’] = "database_name";
  7.   $db[‘default’][‘dbdriver’] = "mysql";
  8.   $db[‘default’][‘dbprefix’] = "";
  9.   $db[‘default’][‘pconnect’] = TRUE;
  10.   $db[‘default’][‘db_debug’] = TRUE;
  11.   $db[‘default’][‘cache_on’] = FALSE;
  12.   $db[‘default’][‘cachedir’] = "";
  13.   $db[‘default’][‘char_set’] = "utf8";
  14.   $db[‘default’][‘dbcollat’] = "utf8_general_ci";
  15.  
  16. }else if($_SERVER[‘HTTP_HOST’] == "192.168.1.1"){
  17.  
  18.   $db[‘default’][‘hostname’] = "localhost";
  19.   $db[‘default’][‘username’] = "root";
  20.   $db[‘default’][‘password’] = "password";
  21.   $db[‘default’][‘database’] = "database_name";
  22.   $db[‘default’][‘dbdriver’] = "mysql";
  23.   $db[‘default’][‘dbprefix’] = "";
  24.   $db[‘default’][‘pconnect’] = TRUE;
  25.   $db[‘default’][‘db_debug’] = FALSE;
  26.   $db[‘default’][‘cache_on’] = FALSE;
  27.   $db[‘default’][‘cachedir’] = "";
  28.   $db[‘default’][‘char_set’] = "utf8";
  29.   $db[‘default’][‘dbcollat’] = "utf8_general_ci";
  30.  
  31. }else{
  32.  
  33.   $db[‘default’][‘hostname’] = "localhost";
  34.   $db[‘default’][‘username’] = "root";
  35.   $db[‘default’][‘password’] = "password";
  36.   $db[‘default’][‘database’] = "database_name";
  37.   $db[‘default’][‘dbdriver’] = "mysql";
  38.   $db[‘default’][‘dbprefix’] = "";
  39.   $db[‘default’][‘pconnect’] = TRUE;
  40.   $db[‘default’][‘db_debug’] = FALSE;
  41.   $db[‘default’][‘cache_on’] = FALSE;
  42.   $db[‘default’][‘cachedir’] = "";
  43.   $db[‘default’][‘char_set’] = "utf8";
  44.   $db[‘default’][‘dbcollat’] = "utf8_general_ci";
  45.  
  46. }

The above code will give the server specific database configuration to the application based on the server it is accessed from.

Now save these two files and test your application you should be able to use the same config.php file in different servers if they are properly configured on config.php and database.php

For any further query feel free to leave a comment I will try my best to help you out.

take care,

thephpx

Share

Sprintometer as a SCRUM management tool

On my endeavor to find the perfect SCRUM project management tool I came across a freeware option named “Sprintometer”. It is not entirely free as it sounds but the options it gives to a manager for free is quite outstanding. The application can be downloaded from their website { sprintometer.com } for free.

Sprintometer support project mangement in both XP and SCRUM methodology. Once you create a project it first of all asks the way the project is going to be managed. Then onward a product backlog can be prepared with stories and tasks assigned to it. Each task then can be assigned to a developer or a coder or a tester.

On the basis of the project specification the application itself generated some very useful charts that give the manager a good understanding about where the project is actually heading. Some of these charts are -

  • Track Chart: Tracks the amount of work done and the amount of work remaining through a line graph.
  • Scope Chart: Shows in hour(s) the amount of work left against a story.
  • Resource and Budget Chart: A matrix showing the resource and cost both story-wise and day-wise
  • Story Readiness Chart: Shows how much closer to completion a story is through a table.
  • Summary Report: Gives a overall report about the story in terms of work done, remaining and days left.
  • Workload Report: This shows the amount of workload taken on by each project team members.

From a project manger perspective it gives me a complete hold on where my project is heading. But the only thing it lacks is integration of team members to give their inputs directly to the system. Hope they are working on it and will be made available to the freeware version in near future :p

take care,

- thephpx

Share

Compress PNG files while retaining quality

Most of today’s site uses PNG images due to use of transparencies. While they give a fine solution to the transparency problem with finer edge but it also brings about page load time issues.

To solve this problem i recently came across a PNG file compression utility.  This tiny utility is hosted on Source Forge and can be downloaded from here. This utility claims to have compressed PNG files upto 50%.

Though the utility is somewhat crude and runs in command prompt but there is a nifty post about how to call it from the windows shell.

For the shell add-on you may visit the following post.

take care,

- thephpx

Share

My Zen-Environment for WAMP development

Hello everyone,

Every developer has there very own zen settings so do i :) . Today I am going to writing about the stuffs I use while I am at development. If you have any better alternatives or suggestions to these applications please feel free to come forward :)

My preferred application development platform includes the following -

Local Work-Station/Laptop:

Central Repository Server Applications:

  • WAMP – for basic windows, apache, mysql, php server on central repository
  • Free SMTP -  for SMTP server on the central repository
  • KpyM Telnet/SSH Server – for SSH access to my central repository
  • VisualSVN – for SVN repository server management at central repository

That is the whole host of applications that are involved in my development process which I find very helpful and agile. I work on two-stage development, my local workstation/laptop and then to my central repository where I host my SVN repositories and also live demos.

The two stage method has so far proven extreamly helpful, specially if you have a VPS account where you are at your will to install applications.

I hope this one helps you setup your zen environment :p.

take care,

- thephpx

Share