"Compilation : Increase performance of any Application "

Short Term

  • Asset Packager
  • Caching – All levels
    • Memcache
    • Action
    • Active Record
    • Fragment
  • combine CSS and JS files with the :cache option
  • avoid HTTP 302 redirects
  • use secondary indices for your database (Rails won’t do this for you)
  • increase SQL-Server query cache
  • SSL only where required
  • Load assets from Subdomain/ different instance , make these environments cookie free
  • Iframe the videos in app
  • Reduce the HTTP request to any page
  • Put all style-sheets at top

    • and compress them to single CSS
    • No Inline CSS
  • Put Scripts to the bottom

    • and compress them to single JS
    • Remove Duplicate scripts
    • No Inline JS
  • Reduce DNS lookups
  • Avoid 301 Redirects
  • Cache and reduce size of Favicon
  • Dont scale images in HTML
  • No empty img src=””
  • Get rid of the extra/unused meta-tags
  • Trim out the white chars
  • Remove the comments
  • Use short names for media included in your website(images, flash files, movies and others)
  • Use relative links instead of full url links


Ongoing :

  • Optimize queries, eager loading of associations with :include and JOIN
  • group operations in a transaction
  • use a Sphinx search server for searching
  • Minimize Response Size
    • SELECT only the needed columns
    • LIMIT the number of return datasets (pagination)
  • Dont use Before Filters for large data
  • Host the server nearer to the user
  • Add Expiry to Header 
  • no 404
  • Reduce Cokiee size


Long term

  • AWS – EC2 AMAZON – Content Delivery Network
  • Compress Assets YUI 
  • use CSS Sprites
  • replace full HTTP requests by XHR requests (i.e. Ajax calls)
  • use counter cache columns
  • denormalize (e.g. comma-separated list of ids in single fields to cache queries)
  • precalculate data through rake tasks
  • Migrating to Rails 3 and Ruby 1.9.2
  • Image caching/compressing
  • Redis
  • Cache option enabled for Js and CSS
  • Configure Etags
  • Cache AJAX requests
  • Use a GET request even if we are doing a AJAX, depending on whether we need to only fetch data or post also
  • Post load components – YUI image loader
  • Pre load some components
  • Reduce number of DOM elements
  • Move irelevant or non-unique content into subpages or popups
  • Remove site-wide links from your footer
  • No tables, tableless design

Ways to test

  • Benchmarking
  • Profiling
  • New Relic
  • Rails Log Analyser
  • Ruby Prof
  • Load Less SQL queries
  • YSLOW

Bibliography



"Compilation : Increase performance of any Application "

"Deploying on Amazon AWS"

How to deloy applications on AWS (Ruby on Rails or LAMP or JAVA etc ).

Was just trying something and thought of saving some of my server cost , and decided to use Amazon AWS instances for it. I know I know .. I am bit late but nevertheless .

Will try to form a basic approach of deploying on AWS , wont cover actual ROR or LAMP deployment , but will try to take you till how we can actually get ssh access , rest post that is routine .

  1. Amazon is currently offering a ‘Free’ (http://aws.amazon.com/ec2/pricing/) service tier in their EC2 cloud, so go ahead and register that .
  2. Once you have registered now, try to create an instance .
  3. Sign into aws.amazon.com and click on Amazon EC2
  4. Click on the “Launch Instance” button and deploy an instance
    • If you want to stay in the ‘Free’ Tier to just try things out, pick a Micro instance which has a big yellow star next to the Select button
    • In my case, I picked the UBUNTU Image
    • As part of setting up the new instance you will be asked to re-use or create a new keypair. This will be important when accessing the Image later on
  5. Login to the EC2 instance you created before.
    • On the Instances page, highlight your instance and select Instance Actions -> Connect
    • A dialog box will indicate how to use an SSH client to access the instance. The command looks something like this:
      ssh -i keypairname.pem ec2-user@ec2-XX-XX-1XX-1XX.us-west-1.compute.amazonaws.com
    • For windows users, see this article about how to use PuTTY to access the Instance (http://docs.amazonwebservices.com/AmazonEC2/gsg/2007-01-19/putty.html)
  6. Once you  have logged into your system using SSH , now you can easilyinstall LAMP, or ROR or whatever you want to. It will be the same way you install these on any other UBUNTU boxes.

EASY pesy !!

Thats it ! Will try to make time and write more of actual ROR and LAMP installations and also DOMAIN mapping in the coming posts .

Thanks !!

"Deploying on Amazon AWS"

"PHP5 – Scripting Language"

PHP is a general-purpose scripting language suited for Web development. The PHP script can be embedded into HTML. This section explains how to install and configure PHP5 in Ubuntu System with Apache2 and MySQL.

This section assumes you have installed and configured Apache 2 Web Server and MySQL Database Server. You can refer to Apache 2 section and MySQL sections in this document to install and configure Apache 2 and MySQL respectively.

Installation

The PHP5 is available in Ubuntu Linux.

  • To install PHP5 you can enter the following command in the terminal prompt:

    sudo apt-get install php5 libapache2-mod-php5
    

    You can run PHP5 scripts from command line. To run PHP5 scripts from command line you should install php5-cli package. To install php5-cli you can enter the following command in the terminal prompt:

    sudo apt-get install php5-cli
    

    You can also execute PHP5 scripts without installing PHP5 Apache module. To accomplish this, you should install php5-cgi package. You can run the following command in a terminal prompt to install php5-cgi package:

    sudo apt-get install php5-cgi
    

    To use MySQL with PHP5 you should install php5-mysql package. To install php5-mysqlyou can enter the following command in the terminal prompt:

    sudo apt-get install php5-mysql
    

    Similarly, to use PostgreSQL with PHP5 you should install php5-pgsql package. To installphp5-pgsql you can enter the following command in the terminal prompt:

    sudo apt-get install php5-pgsql
    

  • Configuration

Once you install PHP5, you can run PHP5 scripts from your web browser. If you have installed php5-cli package, you can run PHP5 scripts from your command prompt.

By default, the Apache 2 Web server is configured to run PHP5 scripts. In other words, the PHP5 module is enabled in Apache2 Web server automatically when you install the module. Please verify if the files /etc/apache2/mods-enabled/php5.conf and /etc/apache2/mods-enabled/php5.load exist. If they do not exists, you can enable the module using a2enmodcommand.

Once you install PHP5 related packages and enabled PHP5 Apache 2 module, you should restart Apache2 Web server to run PHP5 scripts. You can run the following command at a terminal prompt to restart your web server:

sudo /etc/init.d/apache2 restart

Testing

To verify your installation, you can run following PHP5 phpinfo script:

<?php

print_r (phpinfo());
?>

You can save the content in a file phpinfo.php and place it under DocumentRoot directory of Apache2 Web server. When point your browser to http://hostname/phpinfo.php, it would display values of various PHP5 configuration parameters.

"PHP5 – Scripting Language"