<?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>Ian Bicking: a blog &#187; Silver Lining</title>
	<atom:link href="http://blog.ianbicking.org/category/silverlining/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ianbicking.org</link>
	<description></description>
	<lastBuildDate>Wed, 18 Aug 2010 17:39:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Silver Lining: More People!</title>
		<link>http://blog.ianbicking.org/2010/04/21/silver-lining-more-people/</link>
		<comments>http://blog.ianbicking.org/2010/04/21/silver-lining-more-people/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 03:20:00 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=224</guid>
		<description><![CDATA[
OK&#8230; so I said before Silver Lining is for collaborators not users. And that&#8217;s still true&#8230; it&#8217;s not a polished experience where you can confidently ignore the innards of the tool.  But it does stuff, and it works, and you can use it.  So&#8230; I encourage some more of you to do so.
Now [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>OK&#8230; so I said before Silver Lining is for collaborators not users. And that&#8217;s still true&#8230; it&#8217;s not a polished experience where you can confidently ignore the innards of the tool.  But it does stuff, and it works, and you can use it.  So&#8230; I encourage some more of you to do so.</p>
<p>Now would be a perfectly good time, for instance, to port an application you use to the system.  Almost all Python applications should be portable.  The requirements are fairly simple:</p>
<ol class="arabic simple">
<li>The application needs a WSGI interface.</li>
<li>It needs to be Python 2.6 compatible.</li>
<li>Any libraries that aren&#8217;t pure-Python need to be available as deb packages in some form.</li>
<li>Any persistence needs to be provided as a <a class="reference external" href="http://cloudsilverlining.org/services.html">service</a>; if the appropriate service isn&#8217;t already available you may need to write some code.</li>
</ol>
<p>Also PHP applications should work (though you may encounter more rough edges), with these constraints:</p>
<ol class="arabic simple">
<li>No <tt class="docutils literal"><span class="pre">.htaccess</span></tt> files, so you have to implement any URL rewriting in PHP (e.g., <a class="reference external" href="http://bitbucket.org/ianb/silverlining/src/tip/docs/examples/wordpress/runner.php">for WordPress</a>).</li>
<li>Source code is not writable, so self-installers that write files won&#8217;t work.  (Self-installing plugins might be workable, but that hasn&#8217;t been worked out yet.)</li>
<li>And the same constraints for services.</li>
</ol>
<p>So&#8230; take an application, give it a try, and tell me what you encounter.</p>
<p>Also I&#8217;d love to get feedback and ideas from people with more sysadmin background, or who know Ubuntu/Debian tricks.  For instance, I&#8217;d like to handle some of the questions packages ask about on installation (right now they are all left as defaults, not always the right answer).  I imagine there&#8217;s some non-interactive way to handle those questions but I haven&#8217;t been able to find it.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/04/21/silver-lining-more-people/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Core Competencies, Silver Lining, Packaging</title>
		<link>http://blog.ianbicking.org/2010/04/09/core-competencies-silver-lining-packaging/</link>
		<comments>http://blog.ianbicking.org/2010/04/09/core-competencies-silver-lining-packaging/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 22:31:37 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Packaging]]></category>
		<category><![CDATA[Silver Lining]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=220</guid>
		<description><![CDATA[
I&#8217;ve been leaning heavily on Ubuntu and Debian packages for Silver Lining.  Lots of &#34;configuration management&#34; problems are easy when you rely on the system packages&#8230; not for any magical reason, but because the package maintainers have done the configuration management for me.  This includes dependencies, but also things like starting up services [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>I&#8217;ve been leaning heavily on Ubuntu and Debian packages for <a class="reference external" href="http://cloudsilverlining.org">Silver Lining</a>.  Lots of &quot;configuration management&quot; problems are easy when you rely on the system packages&#8230; not for any magical reason, but because the package maintainers have done the configuration management for me.  This includes dependencies, but also things like starting up services in the right order, and of course upgrades and security fixes.  For this reason I really want everything that isn&#8217;t part of Silver Lining&#8217;s core to be in the form of a package.</p>
<p>But then, why isn&#8217;t <em>everything</em> a package?  Arguably some pieces really should be, I&#8217;m just too lazy and developing those pieces too quickly to do it.  But more specifically, why aren&#8217;t applications packages?  It&#8217;s not the complexity really &#8212; the tool could encapsulate all the complexity of packaging if I chose.  I always knew intuitively it didn&#8217;t make sense, but it took me a while to decide quite <em>why</em>.</p>
<p>There are a lot of specific reasons, but the overriding reason is that I don&#8217;t want to <a class="reference external" href="http://www.joelonsoftware.com/articles/fog0000000007.html">outsource a core function</a>.  Silver Lining isn&#8217;t a tool to install database servers.  That is something it does, but that&#8217;s not its purpose, and so it can install a server with <tt class="docutils literal"><span class="pre">apt-get</span> <span class="pre">install</span> <span class="pre">mysql-server-5.1</span></tt>.  In doing so it&#8217;s saving a lot of work, it&#8217;s building on the knowledge of people more interested in MySQL than I, but it&#8217;s also deferring a lot of control.  When it comes to actually deploying applications I&#8217;m not willing to have Silver Lining defer to another system, because deploying applications is the <em>entire point</em> of the tool.</p>
<p>There are many specific reasons.  I want multiple instances of an application deployed simultaneously.  I can optimize the actual code delivery (using rsync) instead of delivering an entire bundle of code. The setup is specific to the environment and configuration I&#8217;ve set up on servers, it&#8217;s not a generic package that makes sense on a generic Ubuntu system.  I don&#8217;t want any central repository of packages or a single place where releases have to go through.  I want to allow for the possibility of multiple versions of an application running simultaneously.  I&#8217;m coordinating services even as I deploy the application, something which Debian packages try to do a <em>little</em>, but don&#8217;t do consistently or well.  But while there&#8217;s a list of reasons, it doesn&#8217;t matter that much &#8212; there&#8217;s no particular size of list that scared me off, and if I&#8217;m misinformed about the way packages work or if there are techniques to avoid these problems it doesn&#8217;t really matter to me&#8230; the real reason is that I don&#8217;t want to defer control over the one thing that Silver Lining <em>must</em> do well.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/04/09/core-competencies-silver-lining-packaging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Web Server Benchmarking We Need</title>
		<link>http://blog.ianbicking.org/2010/03/16/web-server-benchmarking-we-need/</link>
		<comments>http://blog.ianbicking.org/2010/03/16/web-server-benchmarking-we-need/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 23:23:27 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=198</guid>
		<description><![CDATA[
Another WSGI web server benchmark was published.  It&#8217;s a decent benchmark, despite some criticisms.  But it benchmarks what everyone benchmarks: serving up a trivial app really really quickly.  This is not very useful to me.  Also, performance is not to me the most important differentiation of servers.
In Silver Lining we&#8217;re using [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Another <a class="reference external" href="http://nichol.as/benchmark-of-python-web-servers">WSGI web server benchmark</a> was published.  It&#8217;s a decent benchmark, despite some criticisms.  But it benchmarks what everyone benchmarks: serving up a trivial app really really quickly.  This is not very useful to me.  Also, performance is not to me the most important differentiation of servers.</p>
<p>In <a class="reference external" href="http://cloudsilverlining.org">Silver Lining</a> we&#8217;re using <a class="reference external" href="http://code.google.com/p/modwsgi/">mod_wsgi</a>.  Silver Lining isn&#8217;t tied to mod_wsgi (applications can&#8217;t really tell), and we may revisit that decision (mostly because of memory concerns), but it is a deliberate choice.  mod_wsgi is one of the few multiprocess WSGI servers, and it manages its children (the same way Apache manages all its children).  So if a child stops responding, it gets taken out of the pool and killed (brutal efficiency!  Or at least brutal terminology).  Child processes are also recycled, guarding against memory leaks or other peculiarities.  Sometimes these kinds of things are dismissed for covering up bugs, but (a) production is a lousy time to learn about bugs, (b) it&#8217;s like a third tier of garbage collection, and (c) the bugs you are avoiding are often bugs you can&#8217;t fix anyway (for instance, if your mysql driver leaks memory, is that the application developer&#8217;s fault?)</p>
<p>I wish there was competition among servers not to see who can tweak their performance for entirely unrealistic situations, but to see who can implement the most fail-safe server.  We&#8217;re missing good benchmarks.  Unfortunately benchmarks are a pain in the butt to write and manage.</p>
<p>But I hope someone writes a benchmark like that.  Here&#8217;s some things I&#8217;d like to see benchmarked:</p>
<ul class="simple">
<li>A &quot;realistic&quot; CPU-bound application.  <tt class="docutils literal"><span class="pre">for</span> <span class="pre">i</span> <span class="pre">in</span> <span class="pre">xrange(10000000):</span> <span class="pre">pass</span></tt> is a reasonable start.</li>
<li>An application that generates big responses, e.g., <tt class="docutils literal"><span class="pre">&quot;x&quot;*100000</span></tt>.</li>
<li>An I/O bound application.  E.g., one that reads a big file.</li>
<li>A simply slow application (<tt class="docutils literal"><span class="pre">time.sleep(1)</span></tt>).</li>
<li>Applications that wedge.  <tt class="docutils literal"><span class="pre">while</span> <span class="pre">1:</span> <span class="pre">pass</span></tt> perhaps?  Or <tt class="docutils literal"><span class="pre">lock</span> <span class="pre">=</span> <span class="pre">threading.Lock();</span> <span class="pre">lock.acquire();</span> <span class="pre">lock.acquire()</span></tt>.  Wedging in C and wedging in Python are different, so a bunch of different kinds of wedging.</li>
<li>Applications that segfault.  ctypes is specially designed for this.</li>
<li>Applications that leak memory like a sieve, e.g., <tt class="docutils literal"><span class="pre">global_var.extend(['x']*10000)</span></tt>.</li>
<li>Large uploads.</li>
<li>Slow uploads, like a client that takes 30 seconds to upload 1Mb.</li>
<li>Also slow downloads.</li>
<li>In each case it is interesting what happens when something bad happens to just a portion of requests.  E.g., if 1% of requests wedge hard.  A good container will serve the other 99% of requests properly.  A bad container will have its worker pool exhausted and completely stop.</li>
<li>Mixing and matching these could be interesting.  For instance Dave Beazley <a class="reference external" href="http://www.dabeaz.com/blog/2010/02/revisiting-thread-priorities-and-new.html">found some bad GIL results mixing I/O and CPU-bound code</a>.</li>
<li>Add ideas in the comments and I&#8217;ll copy them into this list.</li>
</ul>
<p>The hardest part of writing this is not the applications (they are simple).  One annoyance is wiring up the applications, but handily Nicholas covers that well in <a class="reference external" href="http://nichol.as/benchmark-of-python-web-servers">his benchmark</a>.  You also have to make sure to clean up, as many servers will not exit cleanly from some of the tests.  Another nuisance is that some of these require funny clients.  These aren&#8217;t too hard to write, but you can&#8217;t just use <tt class="docutils literal"><span class="pre">ab</span></tt>.  Then you have to report.</p>
<p>Anyway: I would <strong>love it</strong> if someone did this, and packaged it as repeatable/runnable code/scripts.  I&#8217;ll help some, but I can&#8217;t lead.  I&#8217;d both really like to see the results, and in my ideal world people writing servers would start using these benchmarks to make their servers more robust.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/03/16/web-server-benchmarking-we-need/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Configuration management: push vs. pull</title>
		<link>http://blog.ianbicking.org/2010/03/10/configuration-management-push-vs-pull/</link>
		<comments>http://blog.ianbicking.org/2010/03/10/configuration-management-push-vs-pull/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 01:45:02 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[puppet configuration "configuration management"]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=180</guid>
		<description><![CDATA[
Since I&#8217;ve been thinking about deployment I&#8217;ve been thinking a lot more about what &#34;configuration management&#34; means, how it should work, what it should do.
I guess my quick summary of configuration management is that it is setting up a server correctly.  &#34;Correct&#34; is an ambiguous term, but given that there are so many to [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Since I&#8217;ve been thinking about <a class="reference external" href="http://blog.ianbicking.org/category/silverlining">deployment</a> I&#8217;ve been thinking a lot more about what &quot;configuration management&quot; means, how it should work, what it should do.</p>
<p>I guess my quick summary of configuration management is that it is <em>setting up a server correctly</em>.  &quot;Correct&quot; is an ambiguous term, but given that there are so many to configuration management the solutions are also ambiguous.</p>
<p><a class="reference external" href="http://cloudsilverlining.org">Silver Lining</a> includes configuration management of a sort.  It is very simple.  Right now it is simply a bunch of files to rsync over, and one shell script (you can see the <a class="reference external" href="http://bitbucket.org/ianb/silverlining/src/tip/silverlining/server-files/serverroot/">files here</a> and the <a class="reference external" href="http://bitbucket.org/ianb/silverlining/src/tip/silverlining/server-files/update-server-script.sh">script here</a> &#8212; at least until I move them and those links start 404ing).  Also each &quot;service&quot; (e.g., a database) has a simple setup script.  I&#8217;m sure this system will become more complicated over time, but it&#8217;s <strong>really</strong> simple right now, and I like that.</p>
<p>The other system I&#8217;ve been asked about the most about lately is <a class="reference external" href="http://reductivelabs.com/products/puppet/">Puppet</a>.  Puppet is a <em>real</em> configuration management system.  The driving forces are very different: I&#8217;m just trying to get a system set up that is in all ways <em>acceptable</em> for web application deployment.  I want <em>one</em> system set up for <em>one</em> kind of task; I am completely focused on that end, and I care about means only insofar as I don&#8217;t want to get distracted by those means.  Puppet is for people who care about the means, not just the ends.  People who want things to work in a particular <em>way</em>; I only care that they <em>work</em>.</p>
<p>That&#8217;s the big difference between Puppet and Silver Lining.  The smaller difference (that I want to talk about) is &quot;push&quot; vs. &quot;pull&quot;.  <a class="reference external" href="http://agiletesting.blogspot.com/2010/03/automated-deployment-systems-push-vs.html">Grig wrote up some notes on two approaches</a>.  Silver Lining uses a &quot;push&quot; system (though calling it a &quot;system&quot; is kind of overselling what it does) while Puppet is &quot;pull&quot;.  Basically Silver Lining runs these commands (from your personal computer):</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ rsync -r &lt;silverlining&gt;/server-files/serverroot/ root@<span class="co1">server:/</span><br />
$ ssh root@<span class="co1">server &quot;$(cat &lt;silverlining&gt;/server-files/update-server-script.sh)&quot;</span><br />
&nbsp;</div>
<p>This is what happens when you run <tt class="docutils literal"><span class="pre">silver</span> <span class="pre">setup-node</span> <span class="pre">server</span></tt>: it pushes a bunch of files over to the server, and runs a shell script.  If you update either of the files or the shell script you run <tt class="docutils literal"><span class="pre">silver</span> <span class="pre">setup-node</span></tt> again to update the server.  This is &quot;push&quot; because everything is initiated by the &quot;master&quot; (in this case, the developer&#8217;s personal computer).</p>
<p>Puppet uses a pull model.  In this model there is a daemon running on every machine, and these machines call in to the master to see if there&#8217;s any new instructions for them.  If there are, the daemon applies those instructions to the machine it is running on.</p>
<p>Grig identifies two big advantages to this pull model:</p>
<ol class="arabic simple">
<li>When a new server comes up it can get instructions from the master and start doing things.  You can&#8217;t push instructions to a server that isn&#8217;t there, and the server itself is most aware of when it is ready to do stuff.</li>
<li>If a lot of servers come up, they can all do the setup work on their own, they only have to ask the master what to do.</li>
</ol>
<p>But&#8230; I don&#8217;t buy either justification.</p>
<p>First: servers don&#8217;t just <em>do</em> things when they start up.  To get this to work you have to create custom images with Puppet installed, and configured to know where the master is, and either the image or the master needs some indication of <em>what kind</em> of server you intended to create.  All this is to avoid polling a server to see when it comes online.  Polling a server is lame (and is the best Silver Lining can do right now), but avoiding polling can be done with something a lot simpler than a complete change from push to pull.</p>
<p>Second: there&#8217;s nothing unscalable about push.  Look at those commands: one <tt class="docutils literal"><span class="pre">rsync</span></tt> and one <tt class="docutils literal"><span class="pre">ssh</span></tt>.  The first is pretty darn cheap, and the second is cheap on the master and expensive on the remote machine (since it is doing things like installing stuff).  You need to do it on lots of machines?  Then fork a bunch of processes to run those two commands.  This is not complicated stuff.</p>
<p>It is <em>possible</em> to write a push system that is hard to scale, if the master is doing lots of work.  But just don&#8217;t do that.  Upload your setup code to the remote server/slave and <em>run it there</em>.  Problem fixed!</p>
<p>What are the advantages of push?</p>
<ol class="arabic simple">
<li>Easy to bootstrap.  A bare server can be setup with push, no customization needed.  Any customization is another kind of configuration, and configuration should be automated, and&#8230; well, this is why it&#8217;s a bootstrap problem.</li>
<li>Errors are synchronous: if your setup code doesn&#8217;t work, your push system will get the error back, you don&#8217;t need some fancy monitor and you don&#8217;t need to check any logs.  Weird behavior is also synchronous; can&#8217;t tell why servers are doing something?  Run the commands and watch the output.</li>
<li>Development is sensible: if you have a change to your setup scripts, you can try it out from your machine.  You don&#8217;t need to do anything exceptional, your machine doesn&#8217;t have to accept connections from the slave, you don&#8217;t need special instructions to keep the slave from setting itself up as a production machine, there&#8217;s no daemon that might need modifications&#8230; none of that.  You change the code, you run it, it works.</li>
<li>It&#8217;s just so damn simple.  If you don&#8217;t start thinking about push and pull and other design choices, it simply becomes: do the obvious and easy thing.</li>
</ol>
<p>In conclusion: push is sensible, pull is needless complexity.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/03/10/configuration-management-push-vs-pull/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>toppcloud renamed to Silver Lining</title>
		<link>http://blog.ianbicking.org/2010/03/03/toppcloud-renamed-to-silver-lining/</link>
		<comments>http://blog.ianbicking.org/2010/03/03/toppcloud-renamed-to-silver-lining/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 02:18:30 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Packaging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=168</guid>
		<description><![CDATA[
After some pondering at PyCon, I decided on a new name for toppcloud: Silver Lining.  I&#8217;ll credit a mysterious commenter &#34;david&#34; with the name idea.  The command line is simply silver &#8212; silver update has a nice ring to it.
There&#8217;s a new site: cloudsilverlining.org; not notably different than the old site, just a [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>After some pondering at PyCon, I decided on a new name for toppcloud: <strong>Silver Lining</strong>.  I&#8217;ll credit a mysterious commenter &quot;david&quot; with the name idea.  The command line is simply <tt class="docutils literal"><span class="pre">silver</span></tt> &#8212; <tt class="docutils literal"><span class="pre">silver</span> <span class="pre">update</span></tt> has a nice ring to it.</p>
<p>There&#8217;s a new site: <a class="reference external" href="http://cloudsilverlining.org">cloudsilverlining.org</a>; not notably different than the old site, just a new name.  The product is self-hosting now, using a <a class="reference external" href="http://bitbucket.org/ianb/silverlining/">simple app</a> that runs after every commit to regenerate the docs, and with a small extension to Silver Lining itself (to make it easier to host static files).  Now that it has a real name I also gave it a <a class="reference external" href="http://groups.google.com/group/silverlining-dev">real mailing list</a>.</p>
<p>Silver Lining also has its <a class="reference external" href="http://bitbucket.org/ianb/silverlining/src/tip/tests/functional/runtest.py">first test</a>.  Not an impressive test, but a test.  I&#8217;m hoping with a <a class="reference external" href="http://mail-archives.apache.org/mod_mbox/incubator-libcloud/201003.mbox/browser">VM-based libcloud backend</a> that a full integration test can run in a reasonable amount of time.  <em>Some</em> unit tests would be possible, but so far most of the bugs have been interaction bugs so I think integration tests will have to pull most of the weight.  (A continuous integration rig will be very useful; I am not sure if Silver Lining can self-host that, though it&#8217;d be nice/clever if it could.)</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/03/03/toppcloud-renamed-to-silver-lining/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Why toppcloud (Silver Lining) will not be agnostic</title>
		<link>http://blog.ianbicking.org/2010/02/10/why-toppcloud-not-agnostic/</link>
		<comments>http://blog.ianbicking.org/2010/02/10/why-toppcloud-not-agnostic/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 06:41:45 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=158</guid>
		<description><![CDATA[
I haven&#8217;t received a great deal of specific feedback on toppcloud (update: renamed Silver Lining), only a few people (Ben Bangert, Jorge Vargas) seem to have really dived deeply into it.  But &#8212; and this is not unexpected &#8212; I have already gotten several requests about making it more agnostic with respect to&#8230; stuff. [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>I haven&#8217;t received a great deal of <em>specific</em> feedback on toppcloud (<strong>update</strong>: renamed Silver Lining), only a few people (Ben Bangert, Jorge Vargas) seem to have really dived deeply into it.  But &#8212; and this is not unexpected &#8212; I have already gotten several requests about making it more agnostic with respect to&#8230; stuff.  Maybe that it not (at least forever) require Ubuntu.  Or maybe that it should support different process models (e.g., threaded and multiple processes).  Or other versions of Python.</p>
<p>The more I think about it, and the more I work with the tool, the more confident I am that toppcloud should not be agnostic on these issues.  This is not so much about an &quot;opinionated&quot; tool; toppcloud is not actually very opinionated.  It&#8217;s about a well-understood system.</p>
<p>For instance, Ben noticed a problem recently with <a class="reference external" href="http://code.google.com/p/modwsgi/issues/detail?id=177">weird import errors</a>.  I don&#8217;t know <em>quite</em> why mod_wsgi has this particular problem (when other WSGI servers that I&#8217;ve used haven&#8217;t), but the fix isn&#8217;t that hard.  So Ben <a class="reference external" href="http://bitbucket.org/ianb/toppcloud/changeset/27a470352a5e/">committed a fix</a> and the problem went away.</p>
<p>Personally I think this is a bug with mod_wsgi.  Maybe it&#8217;s also a Python bug.  But it doesn&#8217;t really matter.  When a bug exists it &quot;belongs&quot; to everyone who encounters it.</p>
<p>toppcloud is not intended to be a transparent system.  When it&#8217;s working correctly, you should be able to ignore most of the system and concentrate on the relatively simple abstractions given to your application.  So if the configuration reveals this particular bug in Python/mod_wsgi, then the bug is essentially a toppcloud bug, and toppcloud should (and <em>can</em>) fix it.</p>
<p>A more flexible system can ignore such problems as being &quot;somewhere else&quot; in the system.  Or, if you don&#8217;t define these problems as someone else&#8217;s problem, then a more flexible system is essentially always broken somewhere; there is always some untested combination, some new component, or some old component that might get pushed into the mix.  Fixes for one person&#8217;s problem may introduce a new problem in someone else&#8217;s stack.  Some fixes aren&#8217;t even clear.  toppcloud has Varnish in place, so it&#8217;s quite clear where a <a class="reference external" href="http://bitbucket.org/ianb/toppcloud/changeset/614d5366be67/">fix related to Django and Varnish configuration goes</a>.  If these were each components developed by different people at different times (like with buildout recipes) then fixing something like this could get complicated.</p>
<p>So I feel very resolved: toppcloud will hardcode everything it possibly can.  Python 2.6 and only 2.6!  (Until 2.7, but then <strong>only 2.7</strong>!).  Only Varnish/Apache/mod_wsgi.  I haven&#8217;t figured out threads/processes exactly, but once I do, there will be only one way!  And if I get it wrong, then everyone (<strong>everyone</strong>) will have to switch when it is corrected!  Because I&#8217;d much rather have a system that is inflexible than one that doesn&#8217;t work.  With a clear and solid design I think it is feasible to get this to work, and that is no small feat.</p>
<p>Relatedly, <a class="reference external" href="http://blog.ianbicking.org/2010/02/09/leaving-topp/comment-page-1/#comment-151194">I think I&#8217;m going to change the name of toppcloud</a>, so ideas are welcome!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/02/10/why-toppcloud-not-agnostic/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>toppcloud (Silver Lining) and Django</title>
		<link>http://blog.ianbicking.org/2010/02/05/toppcloud-and-django/</link>
		<comments>http://blog.ianbicking.org/2010/02/05/toppcloud-and-django/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 08:50:58 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=143</guid>
		<description><![CDATA[
I wrote up instructions on using toppcloud (update: renamed Silver Lining) with Django.  They are up on the site (where they will be updated in the future), but I&#8217;ll drop them here too&#8230;

Creating a Layout
First thing you have to do (after installing toppcloud of course) is create an environment for your new application.  [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>I wrote up instructions on using <a class="reference external" href="http://blog.ianbicking.org/2010/01/29/new-way-to-deploy-web-apps/">toppcloud</a> (<strong>update</strong>: renamed Silver Lining) with Django.  They are <a class="reference external" href="http://toppcloud.colorstudy.com/django-quickstart.html">up on the site</a> (where they will be updated in the future), but I&#8217;ll drop them here too&#8230;</p>
<div class="section" id="creating-a-layout">
<h2>Creating a Layout</h2>
<p>First thing you have to do (after installing toppcloud of course) is create an environment for your new application.  Do that like:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ toppcloud init sampleapp<br />
&nbsp;</div>
<p>This creates a directory <tt class="docutils literal"><span class="pre">sampleapp/</span></tt> with a basic layout.  The first thing we&#8217;ll do is set up version control for our project. For the sake of documentation, imagine you go to <a class="reference external" href="http://bitbucket.org">bitbucket</a> and create two new repositories, one called <tt class="docutils literal"><span class="pre">sampleapp</span></tt> and another called <tt class="docutils literal"><span class="pre">sampleapp-lib</span></tt> (and for the examples we&#8217;ll use the username <tt class="docutils literal"><span class="pre">USER</span></tt>).</p>
<p>We&#8217;ll go into our new environment and use these:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ <span class="kw3">cd</span> sampleapp<br />
$ hg clone http://bitbucket.<span class="me1">org</span>/USER/sampleapp src/sampleapp<br />
$ rm -r lib/python/<br />
$ hg clone http://bitbucket.<span class="me1">org</span>/USER/sampleapp-lib lib/python<br />
$ mkdir lib/python/bin/<br />
$ echo <span class="st0">&quot;syntax: glob<br />
bin/python*<br />
bin/activate<br />
bin/activate_this.py<br />
bin/pip<br />
bin/easy_install*<br />
&quot;</span> &gt; lib/python/.<span class="me1">hgignore</span><br />
$ mv bin/* lib/python/bin/<br />
$ rmdir bin/<br />
$ ln -s lib/python/bin bin<br />
&nbsp;</div>
<p>Now there is a basic layout setup, with all your libraries going into the <tt class="docutils literal"><span class="pre">sampleapp-lib</span></tt> repository, and your main application in the <tt class="docutils literal"><span class="pre">sampleapp</span></tt> repository.</p>
<p>Next we&#8217;ll install Django:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ source bin/activate<br />
$ pip install Django<br />
&nbsp;</div>
<p>Then we&#8217;ll set up a standard Django site:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ <span class="kw3">cd</span> src/sampleapp<br />
$ django-admin.<span class="me1">py</span> sampleapp<br />
&nbsp;</div>
<p>Also we&#8217;d like to be able to import this file.  It&#8217;d be nice if there was a <tt class="docutils literal"><span class="pre">setup.py</span></tt> file, and we could run <tt class="docutils literal"><span class="pre">pip</span> <span class="pre">-e</span> <span class="pre">src/sampleapp</span></tt>, but <tt class="docutils literal"><span class="pre">django-admin.py</span></tt> doesn&#8217;t create that itself.  Instead we&#8217;ll get that on the import path more manually with a <tt class="docutils literal"><span class="pre">.pth</span></tt> file:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ echo <span class="st0">&quot;../../src/sampleapp&quot;</span> &gt; lib/python/sampleapp.<span class="me1">pth</span><br />
&nbsp;</div>
<p>Also there&#8217;s the tricky <tt class="docutils literal"><span class="pre">$DJANGO_SETTINGS_MODULE</span></tt> that you might have had problems with before.  We&#8217;ll use the file <tt class="docutils literal"><span class="pre">lib/python/toppcustomize.py</span></tt> (which is imported everytime Python is started) to make sure that is always set:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ echo <span class="st0">&quot;import os<br />
os.environ['DJANGO_SETTINGS_MODULE'] = 'sampleapp.settings'<br />
&quot;</span> &gt; lib/python/toppcustomize.<span class="me1">py</span><br />
&nbsp;</div>
<p>Also we have a file <tt class="docutils literal"><span class="pre">src/sampleapp/sampleapp/manage.py</span></tt>, and that file doesn&#8217;t work <em>quite</em> how we&#8217;d like.  Instead we&#8217;ll put a file into <tt class="docutils literal"><span class="pre">bin/manage.py</span></tt> that does the same thing:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ rm sampleapp/manage.<span class="me1">py</span><br />
$ <span class="kw3">cd</span> ../..<br />
$ echo <span class="st0">'#!/usr/bin/env python<br />
from django.core.management import execute_manager<br />
from sampleapp import settings<br />
if __name__ == &quot;__main__&quot;:<br />
&nbsp; &nbsp; execute_manager(settings)<br />
'</span> &gt; bin/manage.<span class="me1">py</span><br />
$ chmod +x bin/manage.<span class="me1">py</span><br />
&nbsp;</div>
<p>Now, if you were just using plain Django you&#8217;d do something like run <tt class="docutils literal"><span class="pre">python</span> <span class="pre">manage.py</span> <span class="pre">runserver</span></tt>.  But we&#8217;ll be using <tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">serve</span></tt> instead, which means we have to set up the two other files toppcloud needs: <tt class="docutils literal"><span class="pre">app.ini</span></tt> and the runner.  Here&#8217;s a simple <tt class="docutils literal"><span class="pre">app.ini</span></tt>:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ echo <span class="st0">'[production]<br />
app_name = sampleapp<br />
version = 1<br />
runner = src/sampleapp/toppcloud-runner.py<br />
'</span> &gt; src/sampleapp/toppcloud-app.<span class="me1">ini</span><br />
$ rm app.<span class="me1">ini</span><br />
$ ln -s src/sampleapp/toppcloud-app.<span class="me1">ini</span> app.<span class="me1">ini</span><br />
&nbsp;</div>
<p>The file <em>must</em> be in the &quot;root&quot; of your application, and named <tt class="docutils literal"><span class="pre">app.ini</span></tt>, but it&#8217;s good to keep it in version control, so we set it up with a symlink.</p>
<p>It also refers to a &quot;runner&quot;, which is the Python file that loads up the WSGI application.  This looks about the same for any Django application, and we&#8217;ll put it in <tt class="docutils literal"><span class="pre">src/sampleapp/toppcloud-runner.py</span></tt>:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ echo <span class="st0">'import django.core.handlers.wsgi<br />
application = django.core.handlers.wsgi.WSGIHandler()<br />
'</span> &gt; src/sampleapp/toppcloud-runner.<span class="me1">py</span><br />
&nbsp;</div>
<p>Now if you want to run the application, you can:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ toppcloud serve .<br />
&nbsp;</div>
<p>This will load it up on <tt class="docutils literal"><span class="pre">http://localhost:8080</span></tt>, and serve up a boring page.  To do something interesting we&#8217;ll want to use a database.</p>
</div>
<div class="section" id="setting-up-a-database">
<h2>Setting Up A Database</h2>
<p>At the moment the only good database to use is PostgreSQL with the PostGIS extensions.  Add this line to <tt class="docutils literal"><span class="pre">app.ini</span></tt>:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
service.<span class="me1">postgis</span> =<br />
&nbsp;</div>
<p>This makes the database &quot;available&quot; to the application.  For development you still have to set it up yourself.  You should create a database <tt class="docutils literal"><span class="pre">sampleapp</span></tt> on your computer.</p>
<p>Next, we&#8217;ll need to change <tt class="docutils literal"><span class="pre">settings.py</span></tt> to use the new database configuration.  Here&#8217;s the lines that you&#8217;ll see:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
DATABASE_ENGINE = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.</span><br />
DATABASE_NAME = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Or path to database file if using sqlite3.</span><br />
DATABASE_USER = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Not used with sqlite3.</span><br />
DATABASE_PASSWORD = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Not used with sqlite3.</span><br />
DATABASE_HOST = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Set to empty string for localhost. Not used with sqlite3.</span><br />
DATABASE_PORT = <span class="st0">''</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1"># Set to empty string for default. Not used with sqlite3.</span><br />
&nbsp;</div>
<p>First add this to the top of the file:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">import</span> <span class="kw3">os</span><br />
&nbsp;</div>
<p>Then you&#8217;ll change those lines to:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
DATABASE_ENGINE = <span class="st0">'postgresql_psycopg2'</span><br />
DATABASE_NAME = <span class="kw3">os</span>.<span class="me1">environ</span><span class="br0">&#91;</span><span class="st0">'CONFIG_PG_DBNAME'</span><span class="br0">&#93;</span><br />
DATABASE_USER = <span class="kw3">os</span>.<span class="me1">environ</span><span class="br0">&#91;</span><span class="st0">'CONFIG_PG_USER'</span><span class="br0">&#93;</span><br />
DATABASE_PASSWORD = <span class="kw3">os</span>.<span class="me1">environ</span><span class="br0">&#91;</span><span class="st0">'CONFIG_PG_PASSWORD'</span><span class="br0">&#93;</span><br />
DATABASE_HOST = <span class="kw3">os</span>.<span class="me1">environ</span><span class="br0">&#91;</span><span class="st0">'CONFIG_PG_HOST'</span><span class="br0">&#93;</span><br />
DATABASE_PORT = <span class="st0">''</span><br />
&nbsp;</div>
<p>Now we can create all the default tables:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ manage.<span class="me1">py</span> syncdb<br />
Creating table auth_permission<br />
Creating table auth_group<br />
Creating table auth_user<br />
Creating table auth_message<br />
Creating table django_content_type<br />
Creating table django_session<br />
Creating table django_site<br />
...<br />
&nbsp;</div>
<p>Now we have an empty project that doesn&#8217;t do anything.  Let&#8217;s make it do a little something (this is all really based on <a class="reference external" href="http://docs.djangoproject.com/en/dev/intro/tutorial01/">the Django tutorial</a>).</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ manage.<span class="me1">py</span> startapp polls<br />
&nbsp;</div>
<p>Django magically knows to put the code in <tt class="docutils literal"><span class="pre">src/sampleapp/sampleapp/polls/</span></tt> &#8212; we&#8217;ll setup the model in <tt class="docutils literal"><span class="pre">src/sampleapp/sampleapp/polls/models.py</span></tt>:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">from</span> django.<span class="me1">db</span> <span class="kw1">import</span> models<br />
<br />
<span class="kw1">class</span> Poll<span class="br0">&#40;</span>models.<span class="me1">Model</span><span class="br0">&#41;</span>:<br />
&nbsp; &nbsp; question = models.<span class="me1">CharField</span><span class="br0">&#40;</span>max_length=<span class="nu0">200</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; pub_date = models.<span class="me1">DateTimeField</span><span class="br0">&#40;</span><span class="st0">'date published'</span><span class="br0">&#41;</span><br />
<br />
<span class="kw1">class</span> Choice<span class="br0">&#40;</span>models.<span class="me1">Model</span><span class="br0">&#41;</span>:<br />
&nbsp; &nbsp; poll = models.<span class="me1">ForeignKey</span><span class="br0">&#40;</span>Poll<span class="br0">&#41;</span><br />
&nbsp; &nbsp; choice = models.<span class="me1">CharField</span><span class="br0">&#40;</span>max_length=<span class="nu0">200</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; votes = models.<span class="me1">IntegerField</span><span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp;</div>
<p>And activate the application by adding <tt class="docutils literal"><span class="pre">'sampleapp.polls'</span></tt> to <tt class="docutils literal"><span class="pre">INSTALLED_APPS</span></tt> in <tt class="docutils literal"><span class="pre">src/sampleapp/sampleapp/settings.py</span></tt>.  Also add <tt class="docutils literal"><span class="pre">'django.contrib.admin'</span></tt> to get the admin app in place.  Run <tt class="docutils literal"><span class="pre">manage.py</span> <span class="pre">syncdb</span></tt> to get the tables in place.</p>
<p>You can try <tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">serve</span> <span class="pre">.</span></tt> and go to <tt class="docutils literal"><span class="pre">/admin/</span></tt> to login and see your tables.  You might notice all the CSS is broken.</p>
<p>toppcloud serves static files out of the <tt class="docutils literal"><span class="pre">static/</span></tt> directory.  You don&#8217;t actually put <tt class="docutils literal"><span class="pre">static</span></tt> in the URLs, these files are available at the top-level (unless you create a <tt class="docutils literal"><span class="pre">static/static/</span></tt> directory). The best way to put files in there is generally symbolic links.</p>
<p>For Django admin, do this:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
$ <span class="kw3">cd</span> static<br />
$ ln -s ../lib/python/django/contrib/admin/media admin-media<br />
&nbsp;</div>
<p>Now edit <tt class="docutils literal"><span class="pre">src/sampleapp/sampleapp/settings.py</span></tt> and change <tt class="docutils literal"><span class="pre">ADMIN_MEDIA_PREFIX</span></tt> to <tt class="docutils literal"><span class="pre">'/admin-media'</span></tt>.</p>
<p>(Probably some other links should be added.)</p>
<p>One <em>last</em> little thing you might want to do; replace this line in<br />
settings:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
SECRET_KEY = <span class="st0">'ASF#&amp;#64;$&amp;#64;#JFAS#&amp;#64;'</span><br />
&nbsp;</div>
<p>With this:</p>
<div class="dean_ch" style="white-space: wrap;"><br />
<span class="kw1">from</span> tcsupport.<span class="me1">secret</span> <span class="kw1">import</span> get_secret<br />
SECRET_KEY = get_secret<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp;</div>
<p>Then you don&#8217;t have to worry about checking a secret into version control.</p>
<p>You still don&#8217;t really have an application, but the rest is mere &quot;programming&quot; so have at it!</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/02/05/toppcloud-and-django/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A new way to deploy web applications</title>
		<link>http://blog.ianbicking.org/2010/01/29/new-way-to-deploy-web-apps/</link>
		<comments>http://blog.ianbicking.org/2010/01/29/new-way-to-deploy-web-apps/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 20:21:57 +0000</pubDate>
		<dc:creator>Ian Bicking</dc:creator>
				<category><![CDATA[Packaging]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Silver Lining]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.ianbicking.org/?p=132</guid>
		<description><![CDATA[
Deployment is one of the things I like least about development, and yet without deployment the development doesn&#8217;t really matter.
I&#8217;ve tried a few things (e.g. fassembler), built a few things (virtualenv, pip), but deployment just sucked less as a result.  Then I got excited about App Engine; everyone else was getting excited about &#34;scaling&#34;, [...]]]></description>
			<content:encoded><![CDATA[<div class="document">
<p>Deployment is one of the things I like least about development, and yet without deployment the development doesn&#8217;t really matter.</p>
<p>I&#8217;ve tried a few things (e.g. <a class="reference external" href="http://blog.ianbicking.org/2008/06/19/my-experience-writing-a-build-system/">fassembler</a>), built a few things (<a class="reference external" href="http://virtualenv.openplans.org">virtualenv</a>, <a class="reference external" href="http://pip.openplans.org">pip</a>), but deployment just sucked <em>less</em> as a result.  Then I got excited about <a class="reference external" href="http://appengine.google.com">App Engine</a>; everyone else was getting excited about &quot;scaling&quot;, but really I was <a class="reference external" href="http://blog.ianbicking.org/2008/04/09/app-engine-and-open-source/">excited about an accessible deployment process</a>.  When it comes to deployment App Engine is the first thing that has really felt good to me.</p>
<p><strong>But</strong> I can&#8217;t actually <em>use</em> App Engine.  I was able to come to terms with the idea of writing an application to the platform, but there are limits&#8230; and with App Engine there were simply too many limits.  Geo stuff on App Engine is at best a crippled hack, I miss <a class="reference external" href="http://codespeak.net/lxml/">lxml</a> terribly, I never hated relational databases, and almost nothing large works without some degree of rewriting.  Sometimes you can work around it, but you can never be sure you won&#8217;t hit some wall later.  And frankly working around the platform is tiring and not very rewarding.</p>
<hr class="docutils" />
<p>So&#8230; App Engine seemed neat, but I couldn&#8217;t use it, and deployment was still a problem.</p>
<p>What I like about App Engine: an application is just files.  There&#8217;s no build process, no fancy copying of things in weird locations, nothing like that; you upload files, and uploading files <em>just works</em>.  Also, you can check <em>everything</em> into version control.  Not just your application code, but every library you use, the exact files that you installed.  I really wanted a system like that.</p>
<p>At the same time, I started looking into &quot;the cloud&quot;.  It took me a while to get a handle on what &quot;cloud computing&quot; really means.  What I learned: don&#8217;t overthink it.  It&#8217;s not magic.  It&#8217;s just virtual private servers that can be requisitioned automatically via an API, and are billed on a short time cycle.  You can expand or change the definition a bit, but this definition is the one that matters to <em>me</em>.  (I&#8217;ve also realized that I cannot get excited about complicated solutions; only once I realized how simple cloud computing is could I really get excited about the idea.)</p>
<p>Given the modest functionality of cloud computing, why does it matter? Because with a cloud computing system you can actually <em>test</em> the full deployment stack.  You can create a brand-new server, identical to all servers you will create in the future; you can set this server up; you can deploy to it.  You get it wrong, you throw away that virtual server and start over from the beginning, fixing things until you get it right.  Billing is important here too; with hourly billing you pay cents for these tests, and you don&#8217;t need a pool of ready servers because the cloud service basically manages that pool of ready servers for you.</p>
<p>Without &quot;cloud computing&quot; we each too easily find ourselves in a situation where deployments are ad hoc, server installations develop over time, and servers and applications are inconsistent in their configuration.  Cloud computing makes servers disposable, which means we can treat them in consistent ways, testing our work as we go.  It makes it easy to treat operations with the same discipline as software.</p>
<p>Given the idea from App Engine, and the easy-to-use infrastructure of a cloud service, I started to script together something to manage the servers and start up applications.  I didn&#8217;t know what exactly I wanted to do to start, and I&#8217;m not completely sure where I&#8217;m going with this.  But on the whole this feels pretty right.  So I present the provisionally-named: <a class="reference external" href="http://toppcloud.colorstudy.com">toppcloud</a> (<strong>Update</strong>: this has been renamed Silver Cloud).</p>
<hr class="docutils" />
<p>How it works: first you have a directory of files that defines your application.  This probably includes a checkout of your &quot;application&quot; (let&#8217;s say in <tt class="docutils literal"><span class="pre">src/mynewapp/</span></tt>), and I find it also useful to use source control on the libraries (which are put in <tt class="docutils literal"><span class="pre">lib/python/</span></tt>).  There&#8217;s a file in <tt class="docutils literal"><span class="pre">app.ini</span></tt> that defines some details of the application (very similar to <tt class="docutils literal"><span class="pre">app.yaml</span></tt>).</p>
<p>While app.ini is a (<a class="reference external" href="http://toppcloud.colorstudy.com/appconfig.html">very minimal</a>) description of the <em>application</em>, there is no description of the environment.  You do not specify database connection details, for instance.  Instead your application <em>requests</em> access to a database service.  For instance, one of these services is a PostgreSQL/PostGIS database (which you get if you put <tt class="docutils literal"><span class="pre">service.postgis</span></tt> in your app.ini file).  If you ask for that then there will be evironmental variables, <tt class="docutils literal"><span class="pre">CONFIG_PG_DBNAME</span></tt> etc., that will tell your application how to connect to the database.  (For local development you can provide your own configuration, based on how you have PostgreSQL or some other service installed.)</p>
<p>The standard setup is also a <a class="reference external" href="http://virtualenv.openplans.org">virtualenv</a> environment.  It is setup so <em>every time</em> you start that virtualenv environment you&#8217;ll get those configuration-related environmental variables.  This means your application configuration is always present, your services always available.  It&#8217;s available in tests just like it is during a request.  Django accomplishes something similar with the (much maligned) <tt class="docutils literal"><span class="pre">$DJANGO_SETTINGS_MODULE</span></tt> but toppcloud builds it into the virtualenv environment instead of the shell environment.</p>
<p>And how is the server setup?  Much like with App Engine that is merely an implementation detail.  Unlike App Engine that&#8217;s an implementation detail you can actually <em>look</em> at and change (by changing toppcloud), but it&#8217;s not something you are supposed to concern yourself with during regular application development.</p>
<p>The basic lifecycle using toppcloud looks like:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">create-node</span></tt></dt>
<dd>Create a new virtual server; you can create any kind of supported server, but only Ubuntu Jaunty or Karmic are supported (and Jaunty should probably be dropped).  This step is where the &quot;cloud&quot; part actually ends.  If you want to install a bare Ubuntu onto an existing physical machine that&#8217;s fine too &#8212; after <tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">create-node</span></tt> the &quot;cloud&quot; part of the process is pretty much done.  Just don&#8217;t go using some old Ubuntu install; this tool is for clean systems that are used only for toppcloud.</dd>
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">setup-node</span></tt></dt>
<dd>Take that bare Ubuntu server and set it up (or update it) for use with toppcloud.  This installs all the basic standard stuff (things like Apache, mod_wsgi, Varnish) and some management script that toppcloud runs.  This is written to be safe to run over and over, so upgrading and setting up a machine are the same.  It needs to be a bare server, but</dd>
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">init</span> <span class="pre">path/to/app/</span></tt></dt>
<dd>Setup a basic virtualenv environment with some toppcloud customizations.</dd>
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">serve</span> <span class="pre">path/to/app</span></tt></dt>
<dd>Serve up the application locally.</dd>
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">update</span> <span class="pre">--host=test.example.com</span> <span class="pre">path/to/app/</span></tt></dt>
<dd>This creates or updates an application at the given host.  It edits <tt class="docutils literal"><span class="pre">/etc/hosts</span></tt> so that the domain is locally viewable.</dd>
<dt><tt class="docutils literal"><span class="pre">toppcloud</span> <span class="pre">run</span> <span class="pre">test.example.com</span> <span class="pre">script.py</span></tt></dt>
<dd>Run a script (from <tt class="docutils literal"><span class="pre">bin/</span></tt>) on a remote server.  This allows you to run things like <tt class="docutils literal"><span class="pre">django-admin.py</span> <span class="pre">syncdb</span></tt>.</dd>
</dl>
<p>There&#8217;s a few other things &#8212; stuff to manage the servers and change around hostnames or the active version of applications.  It&#8217;s growing to fit a variety of workflows, but I don&#8217;t think its growth is unbounded.</p>
<hr class="docutils" />
<p>So&#8230; this is what toppcloud.  From the outside it doen&#8217;t do a lot.  From the inside it&#8217;s not actually that complicated either.  I&#8217;ve included a lot of constraints in the tool but I think it offers an excellent balance.  The constraints are workable for applications (insignificant for many applications), while still exposing a simple and consistent system that&#8217;s easier to reason about than a big-ball-of-server.</p>
<p>Some of the constraints:</p>
<ol class="arabic simple">
<li>Binary packages are supported via Ubuntu packages; you only upload portable files.  If you need a library like lxml, you need to request that package (<tt class="docutils literal"><span class="pre">python-lxml</span></tt>) to be installed in your app.ini.  If you need a version of a binary library that is not yet packaged, I think creating a new deb is reasonable.</li>
<li>There is no Linux distribution abstraction, but I don&#8217;t care.</li>
<li>There is no option for the way your application is run &#8212; there&#8217;s one way applications are run, because I believe there is a best practice.  I might have gotten the best practice wrong, but that should be resolved inside toppcloud, not inside applications. Is Varnish a terrible cache?  Probably not, but if it is we should all be able to agree on that and replace it.  If there are genuinely different needs then maybe additional application or deployment configuration will be called for &#8212; but we shouldn&#8217;t add configuration just because someone <em>says</em> there is a better practice (and a better practice that is not universally better); there must be justifications.</li>
<li>By abstracting out services and persistence some additional code is required for each such service, and that code is centralized in toppcloud, but it means we can also start to add consistent tools usable across a wide set of applications and backends.</li>
<li>All file paths have to be relative, because files get moved around.  I know of some particularly problematic files (e.g., <tt class="docutils literal"><span class="pre">.pth</span></tt> files), and toppcloud fixes these automatically.  Mostly this isn&#8217;t so hard to do.</li>
</ol>
<p>These particular compromises are ones I have not seen in many systems (and <a class="reference external" href="http://toppcloud.colorstudy.com/comparisons.html">I&#8217;ve started to look more</a>).  App Engine I think goes too far with its constraints.  <a class="reference external" href="http://heroku.com/">Heroku</a> is close, but closed source.</p>
<p>This is different than a strict everything-must-be-a-package strategy.  This deployment system is light and simple and takes into account reasonable web development workflows.  The pieces of an application that move around a lot are all well-greased and agile.  The parts of an application that are better to Do Right And Then Leave Alone (like Apache configuration) are static.</p>
<p>Unlike generalized systems like buildout this system avoids &quot;building&quot; entirely, making deployment a simpler and lower risk action, leaning on system packages for the things they do best.  Other open source tools emphasize a greater degree of flexibility than I think is necessary, allowing people to encode exploratory service integration into what <em>appears</em> to be an encapsulated build (I&#8217;m looking at you buildout).</p>
<p>Unlike <a class="reference external" href="http://pip.openplans.org/requirement-format.html">requirement sets</a> and packaging and versioning libraries, this makes all the Python libraries (typically the most volatile libraries) explicit and controlled, and can better ensure that small updates really are small.  It doesn&#8217;t invalidate installers and versioning, but it makes that process even more explicit and encourages greater thoughtfulness.</p>
<p>Unlike many production-oriented systems (what I&#8217;ve seen in a lot of &quot;cloud&quot; tools) this encorporates both the development environment and production environment; but unlike some developer-oriented systems this does not try to normalize everyone&#8217;s environment and instead relies on developers to set up their systems however is appropriate.  And unlike platform-neutral systems this can ensure an amount of reliability and predictability through extremely hard requirements (it is deployed on Ubuntu Jaunty/Karmic <em>only</em>).</p>
<p>But it&#8217;s not all constraints.  Toppcloud is solidly web framework neutral.  It&#8217;s even <a class="reference external" href="http://toppcloud.colorstudy.com/php.html">slightly language neutral</a>.  Though it does require support code for each persistence technique, it is fairly easy to do, and there are no requirements for &quot;scalable systems&quot;; I think unscalable systems are a perfectly reasonable implementation choice for many problems.  I believe a more scalable system could be built on this, but as a deployment and development option, not a starting requirement.</p>
<p>So far I&#8217;ve done some deployments using toppcloud; not a lot, but some.  And I can say that it feels really good; lots of rough edges still, but the core concept feels really right.   I&#8217;ve made a lot of sideways attacks on deployment, and a few direct attacks&#8230; sometimes I write things that I think are useful, and sometimes I write things that I think are right.  Toppcloud is at the moment maybe more right than useful.  But I genuinely believe this is (in theory) a universally appropriate deployment tool.</p>
<hr class="docutils" />
<p>Alright, so now you think maybe you should look more at toppcloud&#8230;</p>
<p>Well, I can offer you <a class="reference external" href="http://toppcloud.colorstudy.com">a fair amount of documentation</a>.  A lot of that documentation refers to design, and a bit of it to examples.  There&#8217;s also a couple projects you can look at; they are all small, but :</p>
<ul class="simple">
<li><a class="reference external" href="http://bitbucket.org/geraldmc/frank-src/src/tip/build-fs-layout">Frank</a> (will be interactivesomerville.org) which is another similar Django/Pinax project (Pinax was a bit tricky).  This is probably the largest project.  It&#8217;s a Django/Pinax volunteer-written application for collecting community feedback the Boston Greenline project, if that sounds interesting to you might want to chip in on the development (if so <a class="reference external" href="https://projects.openplans.org/greenline">check out the wiki</a>).</li>
<li><a class="reference external" href="http://github.com/ianb/neighborly/blob/master/INSTALL.txt">Neighborly</a>, with minimal functionality (we need to run more sprints) but an installation story.</li>
<li><a class="reference external" href="http://bitbucket.org/ianb/bbdocs/src/tip/create-layout.sh">bbdocs</a> which is a very simple bitbucket document generator, that makes the toppcloud site.</li>
<li><a class="reference external" href="http://bitbucket.org/ianb/geodns">geodns</a> which is another simple no-framework PostGIS project.</li>
</ul>
<hr class="docutils" />
<p>Now, the letdown.  One thing I cannot offer you is support.  <strong>THERE IS NO SUPPORT</strong>.  I cannot now, and I might never really be able to support this tool.  This tool is appropriate for collaborators, for people who like the idea and are ready to build on it.  If it grows well I hope that it can grow a community, I hope people can support each other.  I&#8217;d like to help that happen.  But I can&#8217;t do that by bootstrapping it through unending support, because I&#8217;m not good at it and I&#8217;m not consistent and it&#8217;s unrealistic and unsustainable.  This is not a open source dead drop.  But it&#8217;s also not My Future; I&#8217;m not going to build a company around it, and I&#8217;m not going to use all my free time supporting it.  It&#8217;s a tool I want to exist.  I <strong>very much</strong> want it to exist.  But even very much wanting something is not the same as being an undying champion, and I am not an undying champion.  If you want to tell me what my process <em>should</em> be, please do!</p>
<hr class="docutils" />
<blockquote><p>
If you want to see me get philosophical about packaging and deployment and other stuff like that, see my upcoming talk at <a class="reference external" href="http://us.pycon.org/">PyCon</a>.</p></blockquote>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ianbicking.org/2010/01/29/new-way-to-deploy-web-apps/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.951 seconds -->
