<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Caffeine Lab &#187; web</title>
	<atom:link href="http://erwan.jp/tag/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://erwan.jp</link>
	<description>Really tasty technologies</description>
	<lastBuildDate>Wed, 07 Jul 2010 10:58:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<cloud domain='erwan.jp' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Deploy a Play Application on Gandi Cloud</title>
		<link>http://erwan.jp/2010/02/23/deploy-a-play-application-on-gandi-cloud/</link>
		<comments>http://erwan.jp/2010/02/23/deploy-a-play-application-on-gandi-cloud/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 21:14:23 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[gandi]]></category>
		<category><![CDATA[play framework]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://erwan.jp/?p=478</guid>
		<description><![CDATA[Gandi Cloud is a cloud hosting service, similar to Amazon&#8217;s EC2. Since you get full access to a Linux installation, deployment is similar to using a dedicated server. They have prepackaged solutions for various frameworks but not for Play. Fortunately deploying Play in general is pretty straight-forward. Note that, just like EC2, it&#8217;s not free [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><a href="https://www.gandi.net/hebergement/">Gandi Cloud</a> is a cloud hosting service, similar to Amazon&#8217;s EC2. Since you get full access to a Linux installation, deployment is similar to using a dedicated server. They have prepackaged solutions for various frameworks but not for <a href="http://www.playframework.org">Play</a>. Fortunately deploying Play in general is pretty straight-forward.</p>
<p style="text-align: justify;">Note that, just like EC2, it&#8217;s not free hosting &#8211; you have to pay for it. But they have fairly reasonable prices.</p>
<h3>1. Create a server on Gandi</h3>
<p style="text-align: justify;">Make sure you choose a solution that gives you root access to the machine, &#8220;expert mode&#8221;. In the rest I&#8217;ll assume you choose Ubuntu, but any distribution would work.</p>
<h3>2. Install the Requirements</h3>
<p style="text-align: justify;">ssh to your server, and su to get root access. Now:</p>
<pre style="text-align: justify;">apt-get install openjdk-6-jre unzip</pre>
<p style="text-align: justify;">See how fast is the download, I bet they have a local proxy!</p>
<h3>3. Download Play</h3>
<p style="text-align: justify;">exit to get back to regular user mode, then:</p>
<p style="text-align: justify;">
<pre>wget http://download.playframework.org/releases/play-1.0.1.zip
unzip play-1.0.1</pre>
<h3>4. Run It!</h3>
<p style="text-align: justify;">Now you&#8217;re ready to run your app! Copy your app to your server by using <a href="http://en.wikipedia.org/wiki/Secure_copy">scp</a> for example, switch to to prod mode and you can run:</p>
<pre>play start yourAppFolder</pre>
<p style="text-align: justify;">That&#8217;s it, your application is running on your Gandi cloud server.</p>
<h3>5. HTTP Port, database</h3>
<p style="text-align: justify;">Since it&#8217;s a Cloud environment, you can easily create one server for each app. In this case, just configure Play to run on port 80 and you&#8217;re done. But if one Gandi server part is too big for one application and you can&#8217;t afford buying too many parts, you can run a web front-end to host several Play apps on the same server.</p>
<p style="text-align: justify;">See the Play documentation about <a href="http://www.playframework.org/documentation/1.0.1/production">running in production</a> for instructions on how to do it.</p>
<p style="text-align: justify;">For the database, you could configure one manually on the same server, but it&#8217;s much easier to create a separate MySQL server. You can create a server in &#8220;Gandi AI&#8221; mode, where the server is managed by Gandi and you don&#8217;t have direct access to it. That way, you can create a MySQL servers in a few clicks and point your Play app(s) to that separate server.</p>
<p style="text-align: justify;">
]]></content:encoded>
			<wfw:commentRss>http://erwan.jp/2010/02/23/deploy-a-play-application-on-gandi-cloud/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Simple Tips to Build Scalable Websites</title>
		<link>http://erwan.jp/2009/07/01/scalable-websites/</link>
		<comments>http://erwan.jp/2009/07/01/scalable-websites/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 15:13:17 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[hacking]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[amazon ec2]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[google app engine]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[virtualization]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://erwan.jp/?p=418</guid>
		<description><![CDATA[A few days ago I&#8217;ve been invited to a launch party for a web product in Paris. While the product was nice and polished, it seems like the developers didn&#8217;t understand anything about scalability. They didn&#8217;t even understand my question when I asked them if the product could scale. It&#8217;s probably not a big deal [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I&#8217;ve been invited to a launch party for a web product in Paris. While the product was nice and polished, it seems like the developers didn&#8217;t understand anything about scalability. They didn&#8217;t even understand my question when I asked them if the product could scale.</p>
<p>It&#8217;s probably not a big deal for them: they were presenting a CMS, so most of the time it will be installed for a limited user base. I guess most people will be happy to use it on a single server, so it&#8217;s probably OK for them not to be able to scale. However I noticed that while scalability is now a fairly solved problem, there are not that many articles explaining how to prepare to scalability on the web. So here I go. I will not try to replace a <a href="http://www.amazon.com/Building-Scalable-Web-Sites-applications/dp/0596102356/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1246458871&amp;sr=8-2">good book</a>, but just to give the very basics.</p>
<h3>What is scalability?</h3>
<p>It&#8217;s important to get that out of the way. Scalability is not performance: it&#8217;s not about making good use of CPU and bandwidth, and it&#8217;s not about having the page being loaded quickly in the user&#8217;s browser. It&#8217;s about being able to balance the load between several servers. So when the load increases (more users creating accounts, more visitors, more page views) you can add additional servers to balance the load. You don&#8217;t just throw in a server, you need to design your software to work on a cluster of servers.</p>
<p>An other point is that you will rarely create a cluster of machines from scratch: when you launch a new website you will have few users so few machines (one or two), and as your load increase you will increase the number of servers. You will have to scale different parts of your system one after the other.</p>
<h3>#1: the web front-end</h3>
<p>Most of the time you start with a front-end (PHP, Python, Ruby, Java&#8230;) and a data layer (MySQL, PostgreSQL, CouchDB&#8230;). As your load increase, the front-end will be the first to break. Of course server-side caching will help, but at some point you will need several front-end servers.</p>
<p>The key for that is to ensure you don&#8217;t store any data on the front-end. The problem sometimes arise with sessions: a lot of PHP libraries store session information locally on the server, and that prevents from balancing the load. The idea is that in a session a user may hit a server for a given page, then an other for the next page. If the session is only accessible to the first server, you&#8217;re screwed. You want it to be somewhere else. That can be in the data layer or in a special sessions server. If you write a Facebook app you don&#8217;t need to care, because Facebook takes care of the session.</p>
<p>Now can have as many front-ends as we want, but we have a unique database server.</p>
<h3>#2: the read operations on the database</h3>
<p>Most applications will have many more reads than writes. For example in a blogging software, each visitor will trigger a read on the database (OK, not <em>each</em> visitor if there is a good cache), but writes only occur when the author writes a new post or someone leave a comment.</p>
<p>That&#8217;s good, because it&#8217;s much easier to scale reads than writes. Just make sure that in your code you have different settings for reads and writes. They can point to the same database at launch time, but when the time comes you can separate those. Writes will go to your &#8220;main&#8221; database, and reads will go to a copy. There are other approaches, but for example MySQL offers <a href="http://dev.mysql.com/doc/refman/5.0/en/replication.html">replications</a> features. Once set up, the slaves will stay in sync with the master. You can have as many slaves as you need.</p>
<p>OK &#8211; several front-ends, several read-only databases, but still one master database for writes. If your applications has few reads it may be fine with a beefy database server, (and some major websites just have one master database), but if you have a lot of writes (highly social applications like Facebook or Twitter) you may want to continue the scaling process.</p>
<h3>#3: the write database</h3>
<p>Now we want to have several databases where we can write to. Obviously, we have to be careful not to introduce inconsistencies in the process. So having an old version of a blog post on a server and the new version on an other one is not great; what if some users see an old version of your post and others see the most recent one ?</p>
<p>There are various strategies to divide data in a safe and consistent way, including:</p>
<ul>
<li>Depending on the userid (or blogid, or whatever makes sense in your application), put the data on one server on an other. For example, all users with an even id go to server1 and all users with an odd id go to server2. Hint: make sure your algorithm lets you add more servers later, which is not the case with my example where you will be stuck at 2 servers <img src='http://erwan.jp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Put some tables on a server, some others on an other. It doesn&#8217;t help you when a table is growing too much, but it can be combined with the previous point.</li>
</ul>
<h3>Conclusion</h3>
<p>Here you go, the basics for building a scalable website. That&#8217;s not all you have to do, if your website continues growing you will face more problems such as having to scale your network. I&#8217;m not talking about outgoing bandwidth but communication between your servers (front-end and data layers). But if your code is efficient, those simple recommendation will get you to a server that can handle a fairly big load. I really recommend <a href="http://www.amazon.com/Building-Scalable-Web-Sites-applications/dp/0596102356/ref=sr_1_2?ie=UTF8&amp;s=books&amp;qid=1246458871&amp;sr=8-2">Building Scalable Websites</a>, from O&#8217;Reilly if you want to know more.</p>
<h3>FAQ</h3>
<p><strong><em>Q: Language X doesn&#8217;t scale, but language Y does!</em></strong></p>
<p>A: Bullshit. It&#8217;s not the language that scales, it&#8217;s your code. Some languages may not perform as good as others, so you will have to add boxes more often but the way you scale is still the same.</p>
<p><strong><em>Q: What about cloud computing? Virtualization? All these fancy buzzwords?</em></strong></p>
<p>Virtualization means you run on virtual machines rather than on physical ones. The benefit is that you can easily add or remove machines. For example, using <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> you can add as many machines as you want in a few minutes, and then remove them in no more time. With a classical hosting company, you need to make a phone call, ask for the machines and you get them in maybe one week. They&#8217;ll charge you for the set-up too, and if you no longer want it you still have to pay for a full term. So cloud computing offers are generally more flexible.</p>
<p><em><strong>Q: Does Google App Engine make it easier to scale?</strong></em></p>
<p>In short, yes. By not letting you access the machines, Google App Engine constrain you into writing scalable code. You also don&#8217;t have to request new machines when you need them or release when you no longer need them; you just pay what you use depending on the load of your application.</p>
<p>I am a big fan on Google App Engine but be careful, since it&#8217;s programmed in a particular way it&#8217;s not easy to move your project out of it. You may feel locked in after you project started.</p>
]]></content:encoded>
			<wfw:commentRss>http://erwan.jp/2009/07/01/scalable-websites/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Thoughts on Google App Engine</title>
		<link>http://erwan.jp/2009/05/26/google-app-engine/</link>
		<comments>http://erwan.jp/2009/05/26/google-app-engine/#comments</comments>
		<pubDate>Tue, 26 May 2009 15:33:58 +0000</pubDate>
		<dc:creator>erwan</dc:creator>
				<category><![CDATA[hacking]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[amazons3]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://erwan.jp/?p=405</guid>
		<description><![CDATA[I&#8217;ve been playing with Google App Engine recently. It&#8217;s actually pretty cool, to the point that I&#8217;m almost ashamed to have ignored it when it was released. I kind of felt like it would be too restrictive with just Python, just their own database and so on. But so far, I like it: It&#8217;s only [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been playing with <a href="http://appengine.google.com/">Google App Engine</a> recently. It&#8217;s actually pretty cool, to the point that I&#8217;m almost ashamed to have ignored it when it was released. I kind of felt like it would be too restrictive with just Python, just their own database and so on.</p>
<p>But so far, I like it:</p>
<ul>
<li>It&#8217;s only Python (or Java), but you can do pretty much anything you would do in a non-App Engine Python project. You can load pure pythonic third party libraries by just including them in your project.</li>
<li>The free quotas are really big. It&#8217;s enough for a  hobby project, and if it becomes successful enough to hit the ceiling you should be able to figure out a way to monetize it to pay your Google bill.</li>
<li>You can use your own domain name even with a free account</li>
<li>There is no SQL, but Google&#8217;s BigTable seems to be good enough. Heck, that&#8217;s what they use for most of their products!</li>
</ul>
<p>And you get all the App Engine specific goodness: easy authentication with Google Accounts, free hosting with huge quotas, and most importantly <strong>easy scalability</strong> on Google&#8217;s infrastructure&#8230; Having to call your hosting company to add new servers is a pain in the ass (and in the wallet), having to create and delete instances on <a href="http://aws.amazon.com/s3/">Amazon S3</a> is a much better, but not having to think about it at all is just pure joy.</p>
]]></content:encoded>
			<wfw:commentRss>http://erwan.jp/2009/05/26/google-app-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
