Install Varnish HTTP accelerator with WordPress

 
1 Kudos
Don't
move!

Do you know Varnish?

Varnish cache

Varnish is a web application accelerator. You can install it in front of your web application and it will speed it up significantly. For example Varnish can receive HTTP requests for various production web servers, then caches those requests with a specific TTL to reduce load on the production servers.

Let’s try it!

Install a WordPress.

When your WordPress is installed, just to see what’s inside Varnish, do a test with Apache Bench on your server to get some information about the number of requests per second before and after Varnish.

With our test on the first blog post of our WordPress we got:

Before Varnish : Requests per second: 2.49 [#/sec]

After Varnish : Requests per second:    500.42 [#/sec]

You can try with this simple command from your workstation or any other server:

apt-get install apache2-utils
ab -c 5 -t 30 http://YourServerIP/

Let’s install Varnish…

1 – Get latest version of Varnish

curl http://repo.varnish-cache.org/debian/GPG-key.txt | apt-key add -
echo "deb http://repo.varnish-cache.org/ubuntu/ lucid varnish-3.0" >> /etc/apt/sources.list
apt-get update
apt-get install varnish

2 – Edit Varnish configuration

Edit /etc/varnish/default.vcl

backend default {
            .host = "localhost";
            .port = "8080";
            .max_connections = 30;
            .connect_timeout = 4.0s;
            .first_byte_timeout = 600s;
            .between_bytes_timeout = 600s;
}
# Drop any cookies sent to WordPress.
sub vcl_recv {
            if (!(req.url ~ "wp-(login|admin)")) {
                       unset req.http.cookie;
            }
}
 
# Drop any cookies WordPress tries to send back to the client.
sub vcl_fetch {
            if (!(req.url ~ "wp-(login|admin)")) {
                       unset beresp.http.set-cookie;
            }
}

Edit /etc/default/varnish

DAEMON_OPTS="-a :80
-T localhost:6082
-b localhost:8080
-u varnish -g varnish
-S /etc/varnish/secret
-s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"

Then you need to kill off varnishd:

pkill varnishd

3 – Edit Apache configuration

Edit /etc/apache2/ports.conf to change the listening port of Apache.

NameVirtualHost *:8080
Listen 8080

Edit all your vhosts to match the port 8080

By default in /etc/apache2/sites-available/default

4 – Launch Varnish

Execute the following commands:

/etc/init.d/apache2 restart
varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000

Now everyone accessing your site will be accessing through Varnish.

Note that a very nice plugin has been released for WordPress and Varnish to help Varnish to update his cache when you edit your blog. More information here: http://wordpress.org/extend/plugins/wordpress-varnish/

Boarding to South Korea for business

 
2 Kudos
Don't
move!

I knew very little things about Korea but that it shares one of the world’s most heavily militarised borders with North Korea. It was also my first time in Asia, making it an even more interesting trip!

At that time I was working for Scalr, a Cloud Management Platform. I arrived with its CEO from San Francisco. Right after, its CTO and another Engineer joined us from Ukraine.

Lodging

We rented the apartment on Airbnb and began the journey to move into the city. It took some time especially because our apartment was located near the historic center of Seoul. And it’s rather green and hilly as you can see in the picture taken a few meters away from our apartment. The rented apartment was really nice, we selected that one because it brought together all the typical elements of a Korean or Asian-inspired apartment. Room with tatami mats, wooden floors and sliding doors.

During the first days we visited the historical center of Seoul. Including the Presidential House (Blue House) and the Changdeokgung Palace.

Business work

The purpose of our trip was of course professional and it was time to get ready for about 3 days of presentation of our cloud platform. The show took place at Samsung headquarters, in front of an audience of about 20 engineers. The Samsung campus is a real city named Suwon, also known as Samsung city. Located 40 km south of Seoul, there are just over 40,000 employees.

The presentation went very well, despite the total absence of wifi, which is far from ideal for presenting a platform that manages servers in the cloud. But we quickly realised that security at Samsung is one of the top priorities: multiple scans, passport and ID verification, mobile phones and laptops allowed but under certain conditions: covering up camera lens and webcam with tape.

Korean food and drinks

Another aspect of this trip was the food. We ate Korean at every meal. How often do you go to Korea in your life? Korean cuisine is really varied, you always end up with tons of different things under your nose. Beef, chicken, pork, fish, vegetables, etc… Everything was really delicious, except perhaps the cold noodles (very simply cold pasta that bathes in broth, sometimes spicy).

As for alcohol, soju is the most common. It is a sweet potato alcohol with a very neutral flavour. That makes it a good accompaniment to Korean food. Its taste is comparable to vodka, but a little softer because of the added sugar in the manufacturing process. We had the chance to taste some excellent soju-based cocktails, but beware the soju’s alcohol level varies between 16% and 53% which is relatively strong!

Last but not least, I had my first experience of blowfish and it was delicious. Blowfish is famous for being able to poison you to death, but since we went to a well-known restaurant with a certified chef there was no reason to get worried!

Thank you Korea for welcoming us perfectly and making me want to go back to Asia!