<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://gandikitchen.net/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Gandi Kitchen - Hosting</title>
  <link>http://gandikitchen.net/</link>
  <atom:link href="http://www.gandikitchen.net/feed/tag/Hosting/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>en</language>
  <pubDate>Fri, 13 Jan 2012 09:11:03 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Storage Migration</title>
    <link>http://gandikitchen.net/post/2011/05/05/Storage-Migration</link>
    <guid isPermaLink="false">urn:md5:3f2ae3e8d95ae83f22c092051711d25e</guid>
    <pubDate>Thu, 05 May 2011 15:09:00 +0200</pubDate>
    <dc:creator>Leland Vandervort</dc:creator>
        <category>Hosting</category>
        <category>API</category><category>Hosting</category><category>snapshot</category>    
    <description>&lt;p&gt;For the past few months perhaps you might have made use of the servers in the US.  The changes in the storage technology was one of the strong points in the hosting infrastructure.  Prior to this, we had to adapt the infrastructure so that it could understand &amp;quot;n&amp;quot; datacenters.  The implementation of this new storage platform was not as complicated as it seems since it is completely independent to the architecture in France.  With a new datacenter, it was therefore quite a trivial matter to build from scratch, and all of the new servers in the US made use of this new platform from day one.&lt;/p&gt;    &lt;p&gt;On the French side, an inevitable migration was required in order to arrive at a standardised platform to utilise the new functionalities.  Here, however, the problem is different and a little more complicated, with the coexistence of two different storage solutions.  In reality, we were confronted with a number of challenges so that the machines hosting the servers could happily play ball with two different storage platforms at the same time.  The opening of our US datacenter was already a few months ago, and so a large proportion of our efforts have been dedicated to this migration.  This is, of course, proceeding and certainly takes [a lot of] time, and will soon be available to all of our customers.  We will thus be in a position to run the two storage platforms together in order to perform the migrations efficiently.&lt;/p&gt;
&lt;p&gt;Once active, all new disk creations will take place on the new storage platform.  At this point we will enter the migration phase, and specifically the phase which directly impacts you since it also means the migration of your disks.&lt;/p&gt;
&lt;p&gt;There are a number of ways to perform the migration:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Create a new disk:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The creation of this new disk will be on the new platform.&lt;/p&gt;
&lt;p&gt;Next, simply attach this new disk to your server and copy the relevant data to the new disk.  This would be a good occasion to do some housekeeping and get rid of any old data that you no longer need.  Such commands as 'cp' or 'rsync' would do the job nicely.&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;Create a new disk from the image of an existing one:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This function has been available through the API for several months:  disk.create_from(apikey, disk_spec, src_disk_id) -- see the API documentation for more details at &lt;a href=&quot;http://doc.rpc.gandi.net/hosting/reference.html#disk.create_from&quot;&gt;http://doc.rpc.gandi.net/hosting/reference.html#disk.create_from&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The next Gandi Website update will include the ability to create a new disk from and existing one to make life easier for you if you are not a user of our API.  This method, nevertheless, requires either that the server that has the original disk attached be stopped, or that the disk be detached from the server.&lt;/p&gt;
&lt;p&gt;Please note that the time take to make the copy will be directly dependent upon the size of the disk, so you should have some patience and/or a good coffee break, if you decide to employ this method on a comparatively large disk.&lt;/p&gt;
&lt;p&gt;If the new disk is to be a system disk, then you will need to define the disk as a boot-disk either via the web interface (&amp;quot;Boot Disk&amp;quot; in the server details) or using the API :  vm.disk_attach(apikey, vm_id, disk_id {'position' : 0} )  ( see &lt;a href=&quot;http://doc.rpc.gandi.net/hosting/reference.html#vm.disk_attach&quot;&gt;http://doc.rpc.gandi.net/hosting/reference.html#vm.disk_attach&lt;/a&gt; )&lt;/p&gt;
&lt;p&gt;This migration will enable you, among other things, to make use of the new storage features such as snapshots, resizing, and rapid-copy, which will be available in the coming weeks.  Aside from the platform which is seeing new features every month, we hope to soon be able to talk to you about these new functions which may change the way you use your servers.&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>How to Create a System Images for Your Server</title>
    <link>http://gandikitchen.net/post/2010/11/16/How-to-Create-a-System-Images-for-Your-Server</link>
    <guid isPermaLink="false">urn:md5:17ce0bfdd5be785bcc7b36b4420898da</guid>
    <pubDate>Tue, 16 Nov 2010 16:46:00 +0100</pubDate>
    <dc:creator>Leland Vandervort</dc:creator>
        <category>Hosting</category>
        <category>Hosting</category>    
    <description>&lt;p&gt;There are many reasons to create a system
image for your servers: to build a custom system with your preferred
applications pre-installed, to create an image of a game server that can be
easily deployed, to simply duplicate a custom server, or simply to backup one's
system...&lt;/p&gt;
&lt;p&gt;The procedure is relatively simple and can be performed by anybody, as long as
you pay careful attention to the detail.&lt;/p&gt;    &lt;h2&gt;Create a Data Disk&lt;/h2&gt;
&lt;p&gt;You need to create a data disk via the disk creation interface of your
hosting account.  If you wish to
make a copy of an existing disk, the data disk must be of sufficient capacity.&lt;/p&gt;
&lt;p&gt;Simply attach your new disk to the target server ; the server that contains
the virtual disk to copy, or the server used to perform the base installation.&lt;/p&gt;
&lt;h2&gt;Create a System Image&lt;/h2&gt;
&lt;h3&gt;By making a copy of the data from a virtual
disk.&lt;/h3&gt;
&lt;p&gt;Warning: You must have sufficient space on the destination disk.&lt;/p&gt;
&lt;p&gt;Copy the data from the source disk to the destination with the 'tar'
command:&lt;/p&gt;
&lt;pre&gt;tar cC /srv/disk1 . | tar xC /srv/disk2&lt;/pre&gt;
&lt;p&gt;If /srv/disk1 is the directory where the source disk is mounted and
/srv/disk2 is the mount point of the destination disk.  Using 'tar' will only copy the data and
not empty blocks, so the operation is relatively quick.&lt;/p&gt;
&lt;p&gt;Warning:  if you want to copy
the local system disk, you must add a few exclusions:&lt;/p&gt;
&lt;pre&gt;tar&lt;br /&gt;--exclude=/proc --exclude=/sys --exclude=/srv/disk2 -c \ | tar xC /srv/disk2&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;By installing a base system&lt;/h3&gt;
&lt;h4&gt;Preamble&lt;/h4&gt;
&lt;p&gt;Your new disk attached to a server is ready for use.  You can partition your disk to prepare
a swap partition for the image, but we advise that you do not create  partitions and to create the file
system directly on the disk.&lt;/p&gt;
&lt;p&gt;In this way you have the advantage of flexibility if you intend to resize
the disk later (no need to calculate the partition table), whilst being better
adapted to the block storage on our physical filers, and to be able to decide
later whether or not to use a swap file.&lt;/p&gt;
&lt;p&gt;In the near future, all of the OS images provided by Gandi will be without
partitions, and the Gandi hosting platform will automatically provide
additional swap space.&lt;/p&gt;
&lt;p&gt;Meanwhile, the virtual servers will still see the first disk as
&amp;quot;xvda1&amp;quot; and the swap disk as &amp;quot;xvda2&amp;quot;.&lt;/p&gt;
&lt;p&gt;Whether or not you decide to partition, the Gandi hosting platform will be
able to start a system disk with your image as source by detecting the disk
boot sector and adapting the kernel boot options.  Gandi also provide a server containing copies of the distributions
for which we provide system images. 
You can use this server to speed up your installation :
mirrors.gandi.net&lt;/p&gt;
&lt;h4&gt;Preparation&lt;/h4&gt;
&lt;p&gt;Initially, verify that the virtual disk is not already mounted (for example
in /proc/mounts).  Unmount the disk
if it is mounted.  Partition the
disk if required and then format it.&lt;/p&gt;
&lt;p&gt;We recommend that you format the disk directly and use the ext4 file
system.  If, for example, your disk
is xvdc :  mkfs.ext4 -j -m0
/dev/xvdc  and then mount the disk
to a directory of your system : 
mount -o rw /dev/xvdc /var/tmp&lt;/p&gt;
&lt;h4&gt;Bootstrap installation for distributions using .deb packages&lt;/h4&gt;
&lt;p&gt;The base system installation can be accomplished with debootstrap in a specific
directory.  Once the installation
is completed and a few modifications are made, the disk will contain a bootable
and fully functional GNU/Linux system. 
The system will have a basic set of applications and you will need to
adapt the system to your requirements by installing any required applications
with apt-get and  configuring the
locales.&lt;/p&gt;
&lt;p&gt;We highly recommend the installation of a system with the amd64/x86_64
architecture, as this will be faster on the Gandi platform.  When it comes to selecting the kernel,
you should choose the appropriate x86_64 kernel (2.6.32-3831, for example).&lt;/p&gt;
&lt;p&gt;An example installation for an Ubuntu Maverick 10.10 distribution on a
previously prepared and mounted disk:&lt;/p&gt;
&lt;pre&gt;debootstrap&lt;br /&gt;--arch=amd64 --verbose --components=main,universe,multiverse \&lt;/pre&gt;
&lt;pre&gt;--include=openssh-server,openssh-client&lt;br /&gt;maverick /var/tmp \&lt;/pre&gt;
&lt;pre&gt;http://mirrors.gandi.net/ubuntu/&lt;/pre&gt;
&lt;p&gt;Should debootstrap happen to complain that no configuration file for
maverick is accessible, you only need create a link in
/usr/share/debootstrap/scripts from lucid to maverick.  The following step will modify the file
containing the source package media locations.  Edit the file /etc/apt/sources.list in the directory by adding the distribution media and the Gandi
package media.&lt;/p&gt;
&lt;p&gt;Example :&lt;/p&gt;
&lt;pre&gt;# cat&lt;br /&gt;/var/tmp/etc/apt/sources.list&lt;/pre&gt;
&lt;pre&gt;deb&lt;br /&gt;http://mirrors.gandi.net/ubuntu maverick main universe multiverse&lt;/pre&gt;
&lt;pre&gt;deb&lt;br /&gt;http://mirrors.gandi.net/ubuntu maverick-security main universe multiverse&lt;/pre&gt;
&lt;pre&gt;deb&lt;br /&gt;http://mirrors.gandi.net/ubuntu maverick-updates main universe multiverse&lt;/pre&gt;
&lt;pre&gt;deb&lt;br /&gt;http://mirrors.gandi.net/gandi/ubuntu maverick main&lt;/pre&gt;
&lt;p&gt;Once the debootstrap command and the configuration has been completed, you will
be able to access the newly installed system via chroot to the directory.&lt;/p&gt;
&lt;p&gt;For example: chroot /var/tmp&lt;/p&gt;
&lt;p&gt;In this way, you can refresh the package media with apt-get update  and install the various applications
and packages that you may require. 
Beware, however, that the installation of packages in a chroot require a
few corrections.  Notably, you will
need to mount /proc and /dev/pts which are usually available in /etc/fstab :  mount
-a  then complete the package
configurations with dpkg --configure -a.  Certain packages attempt to
automatically start the daemons and servers as they are installed. You will
have to stop these services to umount your image later.&lt;/p&gt;
&lt;p&gt;In order to complete the installation of these packages, you will need to
modify the postinst files installed in /var/lib/dpkg/info by commenting out the
calls to invoke-rc.d or start, such as with procps : #start procps in procps.postinst or for rsyslog : #invoke-rc.d in rsyslog.posinst.&lt;/p&gt;
&lt;p&gt;For recent Ubuntu distributions, you will need to add an entry for /dev in
the /etc/fstab file:  dev 
/dev  tmpfs  rw  0 0  in
order to boot correctly.&lt;/p&gt;
&lt;p&gt;Next, copy the files /etc/hosts, /etc/resolv.conf and /etc/fstab of the
server to the directory containing the newly installed system (/var/tmp in our
example).  Change these by deleting
the hostname of the current machine in /etc/hosts and adapting /etc/fstab to
your new disk image.&lt;/p&gt;
&lt;p&gt;We recommend installing the gandi-hosting-agent and gandi-hosting-vm
packages available on the Gandi distribution media server.  To do so, add the Gandi maintainer key
as follows:&lt;/p&gt;
&lt;pre&gt;&lt;p&gt;apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D8EAC2F4DAFE3FA5&lt;/p&gt;
&lt;/pre&gt;
&lt;p&gt;then :&lt;/p&gt;
&lt;pre&gt;&lt;p&gt;apt-get install gandi-hosting-agent gandi-hosting-vm&lt;/p&gt;
&lt;/pre&gt;
&lt;h6&gt; &lt;/h6&gt;
&lt;p&gt;The packages will install their required dependencies.  For a description of the functions of
these packages, please refer to the previous article in the Gandi Kitchen.&lt;/p&gt;
&lt;p&gt;If your virtual server uses python version 2.6, you will need to install
the package gandi-hosting-agent-py2.6
instead of gandi-hosting-agent.&lt;/p&gt;
&lt;h4&gt;Basic Installation for Distributions using .rpm&lt;/h4&gt;
&lt;p&gt;The installation of a distribution based on .rpm packages follows the same
method as for a .deb based distribution, but using rinse or a specific application for the chosen distribution.&lt;/p&gt;
&lt;p&gt;For example, using the same directory :&lt;/p&gt;
&lt;pre&gt;&lt;p&gt;rinse --arch=amd64 --directory=/var/tmp --distribution=centos-5&lt;/p&gt;
&lt;/pre&gt;
&lt;h6&gt; &lt;/h6&gt;
&lt;p&gt;According to your package management system, you will need to then add the
package media locations in the configuration in order to install the necessary
applications.&lt;/p&gt;
&lt;p&gt;Please refer to the debootstrap / .deb base system installation for the
remaining step : Gandi specific package installation, copy of system
configuration file.&lt;/p&gt;
&lt;h4&gt;Other Ways to Install a Base System&lt;/h4&gt;
&lt;p&gt;Other distributions (often more specific) have other methods of installing
the base system.  Sometimes an
image is already available, thus you need only mount it in 'loop' and copy the
files from the image.&lt;/p&gt;
&lt;p&gt;Taking the above example :&lt;/p&gt;
&lt;pre&gt;mkdir /srv/a&lt;/pre&gt;
&lt;pre&gt;mount -o loop,ro /my/image/directory /srv/a&lt;/pre&gt;
&lt;pre&gt;cp -raf /srv/a/ /var/tmp/&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;Yet a More Radical Method&lt;/h4&gt;
&lt;p&gt;If you have a source disk to copy, you could also copy the entire
disk;  Ensure that the destination
disk that was just attached to the server is not mounted, and verify that the disk
nameis not present in /proc/mounts.&lt;/p&gt;
&lt;p&gt;Warning : this method only works where the destination disk is the same
size as the source.&lt;/p&gt;
&lt;p&gt;To create your system image and copy it to your new data disk, you will use
the 'dd' command.  You need to pay
close attention to the syntax of the command.&lt;/p&gt;
&lt;p&gt;Here is an example, which will be explained afterwards:&lt;/p&gt;
&lt;h6&gt; &lt;/h6&gt;
&lt;pre&gt;&lt;p&gt;dd if=/dev/xvda of=/dev/xvdc conv=sync&lt;/p&gt;
&lt;/pre&gt;
&lt;p&gt;The parameter if= refers to the source disk; of= refers to, of course, the
destination disk.  Any data on the
destination disk will be completed erased.  In order to distinguish between the disks, we recommend
first using the 'df' command.&lt;/p&gt;
&lt;p&gt;Note that the image will not be bootable.  You will need to reconfigure the network settings of your
server using DHCP before proceeding with the creation of the image.  Copying using 'dd' takes significant
time and resources as it copies byte-per-byte the source disk to the
destination, without any distinction between a data block and an empty
block.  The Linux kernel for the
Gandi hosting platform boots by default on the first partition (
root=/dev/xvda1 on the boot command line).  If you copy an existing system disk, the partition table
will be correct on the destination. 
Otherwise, you should ensure that the first partition of the destination
disk contains the system files and is flagged as bootable.  You can also additionally create a swap
partition.&lt;/p&gt;
&lt;h4&gt;Requirements to Boot&lt;/h4&gt;
&lt;p&gt;In the case of a copy of an existing virtual disk, the source disk having
already booted, you only need to check that the network configuration is using
DHCP so that the produced images will be correctly bootable.  In the case of an image created by a
base system installation, there are a few items to verify and/or modify:&lt;/p&gt;
&lt;p&gt;All of the services or modules related to physical elements of the server
must be deactivated (such as, the service associated with the system clock -
hwclock)&lt;/p&gt;
&lt;p&gt;Some services at boot-time, such as ureadahead, console-setup, ondemand,
plymouth, must be deactivated. 
Move away the init-scripts associated with these services.  In an Ubuntu distribution, these
scripts are found in /etc/init.
&lt;/p&gt;
&lt;p&gt;Add the gandi-hosting-agent and gandi-hosting-vm packages.  The agent allows the installation of
your server to complete.  The
scripts contained in the gandi-hosting-vm package allow the hosting platform to
automatically and dynamically manage the server resources.  For a system with python 2.6, you
should install gandi-hosting-agent-py2.6 instead. For more details on these
packages, please read the  previous
post on the Gandi Kitchen.&lt;/p&gt;
&lt;p&gt;Delete the files related to ssh keys generated during the installation of
the sshd package to avoid having the same key present on all of the servers
generated from the same source image.&lt;/p&gt;
&lt;p&gt;Verify that xinetd/inetd is started at boot -- if not, then activate
it.  The Gandi-agent is spawed via
xinetd/inetd and will enable the final configuration of your server.  The package gandi-hosting-agent
installs its configuration file in /etc/gandi/agent.yml.&lt;/p&gt;
&lt;p&gt;Verify that the permissions of 
your installation directory structure and the directories lib/ root/ and
tmp/ of the installation directory. 
If in doubt, apply the same permissions to these directories as your
existing server outside of the chroot.&lt;/p&gt;
&lt;pre&gt;chmod 0755 /var/tmp/lib&lt;/pre&gt;
&lt;pre&gt;chmod 1777 /var/tmp/tmp&lt;/pre&gt;
&lt;pre&gt;chmod 0750 /var/tmp/root&lt;/pre&gt;
&lt;pre&gt;chmod 0755 /var/tmp/&lt;/pre&gt;
&lt;p&gt;Create the base files in /dev of your installation for the first boot
stages, for example:&lt;/p&gt;
&lt;pre&gt;[ -e &amp;quot;$chroot&amp;quot;/dev/xvc0 ] || mknod &amp;quot;$chroot&amp;quot;/dev/xvc0 c 204 191&lt;/pre&gt;
&lt;pre&gt;[ -e &amp;quot;$chroot&amp;quot;/dev/console ] || mknod &amp;quot;$chroot&amp;quot;/dev/console c 5 1&lt;/pre&gt;
&lt;pre&gt;[ -e &amp;quot;$chroot&amp;quot;/dev/null ] || mknod &amp;quot;$chroot&amp;quot;/dev/null c 1 3&lt;/pre&gt;
&lt;pre&gt;[ -e &amp;quot;$chroot&amp;quot;/dev/ptmx ] || mknod &amp;quot;$chroot&amp;quot;/dev/ptmx c 5 2&lt;/pre&gt;
&lt;pre&gt;[ -e &amp;quot;$chroot&amp;quot;/dev/zero ] || mknod &amp;quot;$chroot&amp;quot;/dev/zero c 1 5&lt;/pre&gt;
&lt;p&gt;Add the necessary kernel modules corresponding to the kernel version in
/lib/modules of your installation directory.  The modules are available on mirrors.gandi.net/kernel/  (See the associated article on the
wiki)&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;At the end of the configuration, if you are inside the chroot, leave it
using 'exit' then unmount the various elements of your images in
/proc/mounts.  Kill any processes
and daemons that may have been started during package installation within the
chroot/directory.  For example
:  grep /var/tmp/proc/mounts and then umount /var/tmp/proc and any others that may be listed.  End by umount /var/tmp which should work without errors.&lt;/p&gt;
&lt;h4&gt;Detach the Disk&lt;/h4&gt;
&lt;p&gt;Return to your disk management interface in your Gandi hosting account, and
detach the disk to which you have just copied, or on which you have just
prepared the installation.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;Make the disk bootable by associating a
kernel&lt;/h4&gt;
&lt;p&gt;In the administration interface, you have the posibility to define a kernel
for a disk.  Select the virtual disk
and associate it with a kernel suitable for the image you have just created.
Let's take a &amp;quot;data&amp;quot; disk as an example, that we want to transform
into a bootable virtual disk:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://gandikitchen.net/public/kitchen-en/bootable-image/s1disk_en.png&quot; alt=&quot;&quot; title=&quot;s1disk_en.png, nov 2010&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Use the link to change the disk
information, and at the bottom of the page you will find an option to change
the disk type:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://gandikitchen.net/public/kitchen-en/bootable-image/s2disk_en.png&quot; alt=&quot;&quot; title=&quot;s2disk_en.png, nov 2010&quot; /&gt; &lt;/p&gt;
&lt;p&gt;You have now
three advanced options, as for a bootable virtual disk:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://gandikitchen.net/public/kitchen-en/bootable-image/s3disk_en.png&quot; alt=&quot;&quot; title=&quot;s3disk_en.png, nov 2010&quot; /&gt;&lt;/p&gt;
&lt;p&gt;By associating a kernel, the disk becomes
usable as a custom image and will be shown in the list of images, just like the
Gandi AI or expert images provided by Gandi during the creation of a new
service via the administration interface.&lt;/p&gt;
&lt;h6&gt; &lt;/h6&gt;
&lt;h4&gt;Create a server from this image&lt;/h4&gt;
&lt;p&gt;During the creation of a server via your administration interface on the
website, you will find your new custom image in the list of available
images.  The server creation will
thus use this image as the source for the system disk.  The server will then normally boot from
a disk which is a copy of your image. 
As such, you have the possibility of creating serveral identical service
from the same custom image.&lt;/p&gt;
&lt;h4&gt; Troubleshooting the server during boot&lt;/h4&gt;
&lt;p&gt;The Gandi hosting platform gives you the ability to access the command line
of your server via the emergency console, which is accessible via an ssh
session, and provides access to the console commandline of your server.&lt;/p&gt;
&lt;p&gt;If you configure a getty on the console by default (tty1, xvc0, hvc0,
depending on the chosen kernel version), you will have an emergency shell in
case of boot errors, or a login prompt in the case of a successful server boot.&lt;/p&gt;
&lt;p&gt;This emergency console will allow you to view the boot messages, and more
importantly, any errors that may occur and thereby allowing you to debug your
image.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;h4&gt;Correcting the Image&lt;/h4&gt;
&lt;p&gt;Later, if you notice errors, or have forgotten anything in your custom
image, you only need re-attach your new disk image to one of your servers
(ultimately, and preferably, a server which was created from the same source
image).  Then you only need make
the changes on the source image and then detach the disk.  The image will thus be available to
create new servers without error.&lt;/p&gt;
&lt;h6&gt; &lt;/h6&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Gandi 10th Anniversary - The Experience</title>
    <link>http://gandikitchen.net/post/2010/03/17/Gandi-10th-Anniversary-The-Experience</link>
    <guid isPermaLink="false">urn:md5:0725b243853c7b857f2f4da85266e035</guid>
    <pubDate>Wed, 17 Mar 2010 19:33:00 +0100</pubDate>
    <dc:creator>Leland Vandervort</dc:creator>
        <category>Hosting</category>
        <category>Hosting</category>    
    <description>&lt;p&gt;To celebrate Gandi's 10th anniversary, this hair-brained idea to give away, in ten days, 55000 domains, raise a very practical question.  How, once we open the floodgates on such an operation, to maintain the highest quality of service on the site?  The festive spirit could well have transformed into a nightmare for our customers if they were suddenly unable to access their management interface.&lt;/p&gt;
&lt;p&gt;So we took the decision to host the event on a dedicated site.  This was a hitherto dreamed of occasion to put ourselves into our customers' shoes, and use our hosting infrastructure for this event.  We defined the rules of play:  Using only the tools provided to our customers, build an architecture which was easily scalable and didn't break the bank, and to demonstrate our renowned flexibility.&lt;/p&gt;    &lt;br /&gt;
&lt;h3&gt;Keep it Simple, Stupid.&lt;/h3&gt;
&lt;p&gt;We had the &amp;quot;luxury&amp;quot; of one week from design to implementation. As a result, the charming idea to demonstrate our &amp;quot;cloudlike&amp;quot; site based on modern technology was summarily put out of our minds. To be perfectly honest, given the time scale, the lucky chosen developer had a nifty precept to select the technology: &amp;quot;You have full choice of the technology, but you have one week.&amp;quot; It would be PHP/MySQL, which isn't exactly everybody's favourite! It would, nevertheless, allow us to release a tested site within the tight time frame.&lt;/p&gt;
&lt;p&gt;To adequately sustain the load generated by such an event, several servers would be needed. We then hit our first stumbling block: Gandi does not [yet] have a load balancing solution for the hosting solution! Nevermind, we'll use the old yet faithful round-robin DNS method, with a low TTL to be able to quickly remove a front-end server from production in case of an incident.&lt;/p&gt;
&lt;p&gt;Our Linux distribution for this occasion would be Ubuntu 9.10 - because it is reasonably up-to-date, with the 2.6.27 kernel.&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Small Servers - Go Forth and Multiply!&lt;/h3&gt;
&lt;p&gt;The best way to sustain the high loads for our solution is to split the functionality among several small servers. This way we would maintain a minimum level of &amp;quot;vertical&amp;quot; scalability (you can dynamically increase the memory and CPU allocated to a server), and the architecture provides &amp;quot;horizontal&amp;quot; scalability.&lt;/p&gt;
&lt;p&gt;In this way we could easily add resources if we started to feel the pinch, and add or migrate shares from one server to another as load requirements necessitate. There are numerous advantages of using multiple small servers:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;each server gets a minimum of one core, burstable, of the CPU (yes, one whole core, even with one share -- that's new, by the way!)&lt;/li&gt;
&lt;li&gt;assured resilience, with shares spread somewhat randomly across a few hundred different physical servers.&lt;/li&gt;
&lt;li&gt;specifically in a virtualised environment, the memory performance is best with less than 1GB of memory.&lt;/li&gt;
&lt;li&gt;if you have 4 servers of one share each, rather than one big server of 4 shares, they can dynamically increase to 8x4 shares, or 24x4 shares with a reboot, and all of this without modification to the architecture. A big server, however, would only scale to 8 shares without a reboot, or 24 after reboot.&lt;/li&gt;
&lt;li&gt;resources may be easily moved towards servers that need it most&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We commence with a simple architecture:&lt;/p&gt;
&lt;ul&gt;&lt;li&gt;24 (!) servers of one share each, to manage the PHP website: 10 for the English site, 10 for the French site, and an additional 2 of each for IPv6.&lt;/li&gt;
&lt;li&gt;2 servers of 4 shares each for replicated memcached to reduce database load and manage sessions.&lt;/li&gt;
&lt;li&gt;1 MySQL server of 4 shares, which contains the pre-generated promotion codes (they actually all fit within memory, so the database itself should really be pretty bored doing nothing...)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After a couple of lovely overloads and a bit of code review, the database would finally be greatly spared by memcached (see the section &amp;quot;&lt;a href=&quot;http://gandikitchen.net/post/2010/03/17/#code&quot;&gt;lightweight coding...&lt;/a&gt;&amp;quot;).&lt;/p&gt;
&lt;p&gt;One of our administrators would put his fingers to work on the site to create and configure 24 servers -- at the same time! Obviously the release of the hosting API or an admin interface function would have been welcome. (Thanks to &lt;ins&gt;cssh&lt;/ins&gt; in this case!)&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Lock Down (somewhat) the Machines&lt;/h3&gt;
&lt;p&gt;A default installation always needs a few finishing touches. The very fact of opening a MySQL database on the &amp;quot;public&amp;quot; network made us a little edgy. So, swooping 'netstat' and shutting down non-critical services listening on public ports. With the help of tcp wrappers (hosts.allow, hosts.deny), all of the &amp;quot;private&amp;quot; interfaces are also locked down (sshd, mysql accessibly only from the web farm).&lt;/p&gt;
&lt;p&gt;Finally it behooved us to pay close attention to the PHP code and MySQL queries; The safest way to avoid php code injections is to bind all the parameters after a prepare(). This also helps reduce load on the database when several execute() are called.&lt;/p&gt;
&lt;p&gt;One important detail: since the site should allow a user to send an email to any &amp;quot;arbitrary&amp;quot; address, it was absolutely critical to limit its potential for abuse by some clever black-hat as much as possible. At the very minimum, the number of sent emails per promotion code was limited, in addition to very close monitoring.&lt;/p&gt;
&lt;br /&gt;&lt;h3&gt;Setup the Development and Deployment Environment&lt;/h3&gt;
&lt;p&gt;The sharing of data between the sites in effect adds a single point of failure, as well as a potential architectural bottleneck. As such, we decided to deploy the content of the site locally on each of the servers. We would use one server for developing and staging, and ultimately for the development and testing of updates. A quick script and some 'rsync' would allow rapid deployment across the entire front-end architecture. Simple! (some would say ;) )&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Resource Monitoring&lt;/h3&gt;
&lt;p&gt;A few moments before the operation, more as a precaution rather than a cure, all of the virtual machines from one to two shares. Using the statistics interface, from day one, one can see that the the virtual machines were essentially sitting &amp;quot;twiddling their thumbs&amp;quot; from boredom ;) :&lt;/p&gt;
&lt;p&gt;&lt;img alt=&quot;CPU on a Front-end Webserver&quot; title=&quot;CPU on a Front-end Webserver, mar 2010&quot; src=&quot;http://www.lacuisinedegandi.net/public/./.console.gandi.net.cpu_m.jpg&quot; /&gt;
&lt;img alt=&quot;Network interface on a front-end Websever&quot; title=&quot;Network interface on a front-end Webserver, mar 2010&quot; src=&quot;http://www.lebardegandi.net/public/./.console.gandi.net.vif_m.jpg&quot; /&gt;
&lt;/p&gt;
&lt;p&gt;It would have been cool, at this very moment, to reduce back to a single share per server, or make use of Gandi &amp;quot;Autoflex&amp;quot;, or even given the actual load observed, set up scheduled flex for each hour to hand out the promotion codes! Unfortunately, with all hands on deck, we missed this opportunity to demonstrate this [econono-techno-ecological ;)] feature.&lt;/p&gt;
&lt;br /&gt;
&lt;h3 id=&quot;code&quot;&gt;Lightweight Code is Worth More than a Thousand Beefy CPUs&lt;/h3&gt;
&lt;p&gt;Even though we physically had several thousand CPUs and a few Terabytes of RAM at our fingertips, Tuesday turned out to be somewhat chaotic and worthy of note here. After Monday, which managed the load very well, the &amp;quot;smooth&amp;quot; execution of our one and only SELECT COUNT brutally altered and became excruciatingly slow (300ms). We had naively thought that this &amp;quot;only&amp;quot; query, on a table held exclusively in memory, wouldn't be an issue. As such, it was executed on every page of the site. The multiple simultaneous accesses to the database, coupled with the UPDATE operations for the promotion codes, resulted in the database, despite the near-idle system performance, started causing database lock contention.&lt;/p&gt;
&lt;p&gt;The usual knee-jerk reaction to such a situation is to increase the number of shares to support the load. It's great for a quick-fix temporary solution, but it's not enough!&lt;/p&gt;
&lt;p&gt;A new analysis of the system, questions about the code, and the use (or salvation) of memcached resulted in recovering the optimal performance. Equally, a modification of the database queries used probably would have been prudent.&lt;/p&gt;
&lt;p&gt;The moral of the story: the code, indexes, architecture (etc.) are the cornerstones of your ability to support usage load, and if they are &amp;quot;CPU friendly&amp;quot;, they will save the day. Otherwise a catastrophe could be lurking, or at the very least, the unnecessary purchase of additional shares.&lt;/p&gt;
&lt;p&gt;Also, as we said earlier somewhat tongue-in-cheek -- it's eco-friendly!&lt;/p&gt;
&lt;br /&gt;
&lt;h3&gt;Some Numbers&lt;/h3&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;36 shares total, but we could have done it with less (*sniff*)&lt;/li&gt;
&lt;li&gt;5% CPU usage at peak&lt;/li&gt;
&lt;li&gt;4000 requests per front-end web server in the first minute of each hour (roughly 1400 requests/second total)&lt;/li&gt;
&lt;li&gt;a minimum of 11 seconds to hand out 1000 promotion codes.&lt;/li&gt;
&lt;li&gt;a maximum of 40 minutes to hand out the same number of promotion codes, during the Tuesday incident described above.&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>
