Elastic Load Balancing with Sticky Sessions

Thursday, August 23, 2012
Before starting the post,i would like to explain about sticky session,
What is Session Affinity (Sticky Sessions)?
When you only have one application server talking to your clients life is easy:
all the session contexts can be stored in that application server’s memory for fast retrieval. But in the world of highly available and scalable applications there’s likely to be more than one application server fulfilling requests, behind a load balancer. The load balancer routes the first request to an application server, who stores the session context in its own memory and gives the client back a cookie. The next request from the same client will contain the cookie – and, if the same application server gets the request again, the application will rediscover the session context. But what happens if that client’s next request instead gets routed to a different application server? That application server will not have the session context in its memory – even though the request contains the cookie, the application can’t discover the context.

If you’re willing to modify your application you can overcome this problem. You can store the session context in a shared location, visible to all application servers: the database or memcached, for example. All application servers will then be able to lookup the cookie in the central, shared location and discover the context. Until now, this was the approach you needed to take in order to retain the session context behind an Elastic Load Balancer.

But not all applications can be modified in this way. And not all developers want to modify existing applications. Instead of modifying the application, you need the load balancer to route the same client to the same application server. Once the client’s request has been routed to the correct application server, that application server can lookup the session cookie in its own memory and recover the conversational context.

That’s what sticky sessions are:
the load balancer routing the same client to the same application server. And that’s why they’re so important: If the load balancer supports sticky sessions then you don’t need to modify your application to remember client session context.

"How to Use ELB with Sticky Sessions with Existing Applications

The key to managing ELB sticky sessions is the duration of the stickiness: how long the client should consistently be routed to the same back-end instance. Too short, and the session context will be lost, forcing the client to login again. Too long, and the load balancer will not be able to distribute requests equally across the application servers.

How to get all associated products to a configurable product in Magento

Saturday, August 18, 2012
Configurable product is the product which is created by some Associated product, If you have an configurable product and you want to get list of all associated product and it's attribute then, follow the below code:You must have your configurable product Id, My configurable product Id is 10
 
$proId=10; //Use your Configurable product Id
$_product = new Mage_Catalog_Model_Product();

How to change Admin URL Path?

I will show you, how you can change the admin url. Let’s say from ‘admin‘ to ‘administrater‘. So, the new admin URL will be http://www.magento.com/administrater/
Here is how we do it:-

How to setup MySQL Master-Slave Replication on magento

Wednesday, April 11, 2012
This is an article to show you ,how you can set MySql Master-slave replication in magento for scalability ,handle failover and performance.
You will have to use Slave database for read (select queries) Operations and Master database for write( insert and update queries).
Make changes in the following config file of magento:
app/etc/local.xml

<default_setup>
<connection>
<host><![CDATA[Master-host]]></host>
<username><![CDATA[user]]></username>
<password><![CDATA[pass]]></password>
<dbname><![CDATA[magentodb]]></dbname>
<active>1</active>
</connection>
</default_setup>

Integrate Memcached in Magento

Saturday, March 17, 2012
Integrate memcache in your magento application which will increase the speed of Magento page loads as much as possible..In this this article i will tell you how you can do it.
Magento has built in support of memcached ,you only need to enabled it by making some changes in the configuration file.
Memcached is a high-performance memory object caching system that is designed to speed page loads on dynamic content websites. Magento supports Memcached for caching many objects, but it is not enabled by default and will require some simple changes to your configured local.xml file to use.

First, be sure that Memcached is installed and running on your server. It by default listens on port 11211. A ‘netstat’ will verify that you do indeed have a Memcached listening socket on port 11211 indicating that is it running. Configuring Memcached to listen on localhost is recommended as it would be a security risk allowing any external sources access Memcached directly if it were to be listening on an external ip that wasn’t firewalled.

You also need to be sure that Memcached support is loaded into PHP. A view on a phpinfo() page can verify this, just look for the ‘Memcache’ block in the phpinfo and be sure it is ‘enabled’.

To enable Memcached within Magento, you will need to add the following block of code to your app/etc/local.xml file:

Call Static Blocks From Any PHTML File in Magento

Wednesday, December 14, 2011
In this article i am going to show you...How to call a static block from any template(.phtml) file in Magento.You can easily call any static block from template (phtml) file. At first, you have to create a static block from admin, CMS->Static Blocks .
Let us suppose, you created a static block with the identifier footer_links.
Now, you can call the static block from any phtml file with the help of following code:
<?php echo $this->getLayout()->createBlock('cms/block')
->setBlockId('footer_links')->toHTML();?>

Use any SMTP to send mail in Magento

Sunday, December 11, 2011
This article will explain how to create an extension to send all the emails through gmail or other servers.I have created an module to set up an email account from admin.
I have made use of "Zend_Mail_Transport_Smtp" class to make it possible.