<?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>Building Browsergames &#187; server</title>
	<atom:link href="http://buildingbrowsergames.com/category/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://buildingbrowsergames.com</link>
	<description>Ever wanted to build a browsergame?</description>
	<lastBuildDate>Mon, 29 Mar 2010 14:00:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Save bandwidth while improving performance!</title>
		<link>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/</link>
		<comments>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 14:00:32 +0000</pubDate>
		<dc:creator>donbonifacio</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[site]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=737</guid>
		<description><![CDATA[Bandwidth can be very troublesome, especially if you&#8217;re at a limited hosting solution, with only a small amount of gigabytes to serve per month. If your site uses a substantial quantity of images and scripts, you may find yourself having a big problem.
Lets imagine that a new user goes to your site and he/she will [...]]]></description>
			<content:encoded><![CDATA[<p>Bandwidth can be very troublesome, especially if you&#8217;re at a limited hosting solution, with only a small amount of gigabytes to serve per month. If your site uses a substantial quantity of images and scripts, you may find yourself having a big problem.</p>
<p>Lets imagine that a new user goes to your site and he/she will need to download 100kb of scripts and images, plus the XHTML page. If you have 50.000 requests, you&#8217;ll serve a significant quantity of bandwidth. And you may even serve static content to old users if you don&#8217;t configure correctly your static content headers.</p>
<h3>Step 1 &#8211; Decouple the static content from the dynamic content</h3>
<p>First you need to prepare your game to be able to get your images/scripts from anywhere. Instead of linking like:</p>
<pre>&lt;img src="/Images/Sample.png" /&gt;</pre>
<p>You need to code your application to link like:</p>
<pre>&lt;img src="http://some_host/Images/Sample.png" /&gt;</pre>
<p>And have the <strong>http://some_host</strong> easily configurable somewhere. That way you&#8217;ll be able to change the location of your static content and make use of <em>content distribution networks</em>. This can be a complex task if you leave it to the end, so you should start as soon as possible using this strategy. Note that this way you may still use your main server URL for static content.</p>
<h3>Step 2 &#8211; Use a Content Distribution Network</h3>
<p>Now that you have a configurable static content location, you have several options to consider. For example, if your game is open source, you may create an account at <a href="http://sf.net">SourceForge.net</a> and then you&#8217;ll have your own web space to use. You could then configure your game to use as a location for static content something like:</p>
<pre>http://your_game_name.sourceforge.net</pre>
<p>And that&#8217;s it! You&#8217;d save a lot of bandwidth and server load just by changing some configuration. But having an open source game isn&#8217;t always an option. Fortunately, there&#8217;s a free content distribution network named <a href="http://www.coralcdn.org/">Coral CDN</a> that is very easy to use. Imagine that your game is at the <em>http://your_game_name.com</em> url and that you configured your static content location to <strong>http://your_game_name.com</strong>. To use Coral CDN you&#8217;d have just to change the static location to:</p>
<pre>http://your_game_name.com.nyud.net</pre>
<p>Appending the <em>&#8220;.nyud.net&#8221;</em> will make Coral to automatically act as a proxy to your content and cache it. For example, you can try it at this site: <a href="http://buildingbrowsergames.com.nyud.net/">buildingbrowsergames.com.nyud.net</a>.</p>
<p>There are other CDN solutions out there, some will cost more money and will be better. A great advantage of CDNs is that they have servers all over the world and will sync your data all over them. So, if your server is in England but you have a user from Japan, the CDN will serve the static content from the nearest server, and your user won&#8217;t need to fetch content from the other part of the world.</p>
<h3>Step 3 &#8211; Configure Static Content Headers</h3>
<p>So, by now you don&#8217;t have to worry about bandwidth, because you&#8217;ll have a third party serving it for you. But there&#8217;s something more you can do to improve user experience. When a browser requests content it may cache it according to the server configuration. But if you don&#8217;t configure the server properly, the browser may ask for the same static file over and over again.</p>
<p>This won&#8217;t be costly for you, but for the user experience. If a user makes a request to your game and the browser has everything cached, the request will be almost instantaneous! However, if the browser needs to refresh data, it may ask for the static content again, and that may implicate that your user will have to wait a second and see loading images.</p>
<h3>Resources</h3>
<p>This article is just an introduction to make you aware of static content problems and how to solve them. To learn more about client side performance, you can study the <a href="http://developer.yahoo.com/performance/rules.html">Yahoo&#8217;s Best Practices for Speeding Up Your Web Site</a>. They have a lot of useful tips, and if you use Firefox, you may install <a href="http://developer.yahoo.com/yslow/">YSlow</a>, an extension that will rate your site in terms of client side performance.</p>
<p>Another great tool to use is something like <a href="http://www.fiddlertool.com/fiddler/">Fiddler</a>, that allows you to see all requests made by the browser, headers, and so on. By using it you&#8217;ll see where you can improve.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2009/02/13/save-bandwidth-while-improving-performance/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why you should deploy your game with source control</title>
		<link>http://buildingbrowsergames.com/2008/11/27/why-you-should-deploy-your-game-with-source-control/</link>
		<comments>http://buildingbrowsergames.com/2008/11/27/why-you-should-deploy-your-game-with-source-control/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 14:00:21 +0000</pubDate>
		<dc:creator>Luke</dc:creator>
				<category><![CDATA[server]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[sourcecontrol]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://buildingbrowsergames.com/?p=586</guid>
		<description><![CDATA[One of the things that you may have noticed while following along with our tutorial is that each time we add a new feature, we start with a fresh checkout of the current version on our Google Code repository. This is for two reasons:

We get a completely &#8216;fresh&#8217; version of our code &#8211; there won&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things that you may have noticed while following along with our tutorial is that each time we add a new feature, we start with a fresh checkout of the current version on our Google Code repository. This is for two reasons:</p>
<ol>
<li>We get a completely &#8216;fresh&#8217; version of our code &#8211; there won&#8217;t be any changes or differences between the versions that someone else and I am both using(assuming we checked out the same revision).</li>
<li>You should be keeping all of your changes in a repository &#8211; which is why after we have made our changes, they&#8217;re committed back.</li>
</ol>
<p>Now, this is all well and good &#8211; but how are you deploying your projects?</p>
<p>Typically, I see people deploying their projects by opening up their favorite FTP client, connecting to their server, and uploading the files &#8211; and then afterwards, testing their changes to make sure they didn&#8217;t break anything. However, one of the other advantages of keeping things under source control is that you can check out your code from <strong>anywhere</strong>, as long as you have configured it properly. What this means is that you can also use source control to deploy your projects, making it much easier to keep track of which version of the game is currently deployed(and also do updates as necessary).</p>
<p>To begin with, you will need to have your source control repositories hosted at a location which you can access from your server &#8211; I prefer hosted source control, and typically use either <a href='http://unfuddle.com/'>Unfuddle</a> or <a href='http://beanstalkapp.com/'>Beanstalk</a>. Beanstalk is prettier, but Unfuddle gives you an infinite number of repositories for free(while Beanstalk will only give you one before you have to pay).</p>
<p>After setting up your repository and importing your project, you can do source control-based deploys by logging into your server and checking out a copy of your code(Subversion command shown):</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">svn co svn://your-repo-name.repohost.com /www/yoursite.com/game</pre></div></div>

<p>Once that command has been issued(and any required authentication has been done), you should have a brand new, fresh copy of all of your game&#8217;s code sitting on your server.</p>
<p>Now, thus far you may have been reading along and thinking &#8220;this is cool and all, but why would I ever need this? Deploying by FTP works fine for me.&#8221;. And, to be fair, if you prefer to deploy by FTP you can do that. But deploying from source control becomes useful <strong>after the initial deploy</strong>, for two big reasons(and one smaller one):</p>
<ol>
<li>You can see <em>exactly</em> which version of your codebase you are currently running.</li>
<li>As long as you&#8217;re strict enough about it, the code running on your server will be <strong>exactly</strong> the same as any code you have access to; so if something goes wrong with the currently deployed version, you can retrieve the exact same code, and then sort the problem out.</li>
<li>Updating your game requires less bandwidth &#8211; as only the files that have changed will be downloaded to your server.</li>
</ol>
<p>How do you figure out which version of your code is currently checked out? Just go to a directory with the checked out code inside, and run this command:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">svn info</pre></div></div>

<p>Once you&#8217;ve done that, you should see a bunch of information about the version of your code that you are running the command on:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">Path: .
URL: svn://your-repo-name.repohost.com/trunk
Repository Root: svn://your-repo-name.repohost.com
Repository UUID: 28cb6aaa-c762-4a6a-b8a9-6d82464dce74
Revision: 252
Node Kind: directory
Schedule: normal
Last Changed Author: Luke
Last Changed Rev: 249
Last Changed Date: 2008-11-20 14:08:31 -0700 (Thu, 20 Nov 2008)</pre></div></div>

<p>And if you&#8217;d like to see the commit message for the revision that is currently checked out:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">svn log --limit 1</pre></div></div>

<p>You can change the value that you pass to <em>limit</em>(or remove it entirely) if you&#8217;d like to see more log messages.</p>
<p>However, as cool as all of this is, it doesn&#8217;t really get us to the nicest part of deploying this way: <strong>the ability to update and roll back files easily and instantaneously</strong>.</p>
<p>Let&#8217;s say that you&#8217;ve been updating little bits and pieces of your game, and you&#8217;ve noticed that <strong>combat.php</strong> has a bug in it that is currently preventing users from picking up items. Now, if you were using FTP to deploy your game, you would need to make the fix, upload the new file, and hope for the best. But what would happens if by fixing that bug, you introduce a new one that breaks things even more? If you&#8217;ve only been using FTP to deploy your game, <strong>there is no way to roll back</strong>. But if you&#8217;ve been using source control, rolling back to a previous version is easy:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">svn up combat.php -r 26</pre></div></div>

<p>Now, assuming that revision 26 had a working combat.php, your version of combat.php would revert back to the old, working version &#8211; giving you time to fix the bug. After you had fixed the bug, you&#8217;d be able to easily bring <strong>combat.php</strong> back up to date:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">svn up combat.php</pre></div></div>

<p>As you can see, deploying your game using source control gives you a lot more flexibility when it comes to rolling out updates to your game &#8211; you can use files from different revisions, keep track of which version of your game is deployed, and easily roll back to a previous version(or deploy a fixed version) if something goes wrong &#8211; without having to worry about accidentally over-writing anything.</p>
<p>Deploying with source control also makes it easy for you to keep multiple versions of your game available: for example, if you wanted to have a testing ground for new features, the version of the game that was currently playable by your users, and an older, legacy version &#8211; all you would need to do is check out different revisions of your code in each of the directories you were planning to put those versions in.</p>
<p>As you can see, source control is an extremely useful tool, even if you aren&#8217;t using it for collaboration &#8211; and when you have more than one developer, having source control in place is virtually the only way to collaborate with them effectively.</p>
]]></content:encoded>
			<wfw:commentRss>http://buildingbrowsergames.com/2008/11/27/why-you-should-deploy-your-game-with-source-control/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

