<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Usu's Blog</title>
	
	<link>http://usu.li/blog</link>
	<description />
	<lastBuildDate>Sat, 18 Jun 2011 16:19:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Usus-Blog" /><feedburner:info uri="usus-blog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Wanna play Les Paul Google Doodle forever and ever?</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/VQa284-smfk/</link>
		<comments>http://usu.li/blog/wanna-play-les-paul-google-doodle-forever-and-ever/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 08:51:44 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[doodle]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=203</guid>
		<description><![CDATA[Thanks to gensanblog.com who ripped it and made it available for everyone, I mirrored it here for neverending fun. Google ♥]]></description>
			<content:encoded><![CDATA[<p>Thanks to <a title="gensanblog.com" href="http://gensanblog.com/2011/06/09/google-les-pauls-96th-birthday-june-09-2011/" target="_blank">gensanblog.com</a> who ripped it and made it available for everyone, <a title="les paul google doodle" href="http://usu.li/doodle/">I mirrored it here</a> for neverending fun.</p>
<p>Google ♥</p>
<div id="tweetbutton203" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fwanna-play-les-paul-google-doodle-forever-and-ever%2F&amp;via=andreausu&amp;text=Wanna%20play%20Les%20Paul%20Google%20Doodle%20forever%20and%20ever%3F&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fwanna-play-les-paul-google-doodle-forever-and-ever%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/VQa284-smfk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/wanna-play-les-paul-google-doodle-forever-and-ever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://usu.li/blog/wanna-play-les-paul-google-doodle-forever-and-ever/</feedburner:origLink></item>
		<item>
		<title>Simulate real users load on a webserver using Siege and Sproxy</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/NniumwnpGgY/</link>
		<comments>http://usu.li/blog/simulate-real-users-load-on-a-webserver-using-siege-and-sproxy/#comments</comments>
		<pubDate>Wed, 18 May 2011 09:54:02 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[siege]]></category>
		<category><![CDATA[sproxy]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=148</guid>
		<description><![CDATA[We all know ApacheBench which is a really great tool for &#8220;brute-force&#8221; benchmarking, but what if we need to simulate n real users browsing a website in a plausible way? [...]]]></description>
			<content:encoded><![CDATA[<p>We all know ApacheBench which is a really great tool for &#8220;brute-force&#8221; benchmarking, but what if we need to simulate n real users browsing a website in a plausible way?</p>
<p>Well, Siege and Sproxy serve this exact purpose!<br />
Sproxy is a proxy that we can use to collect a list of urls to feed Siege with, let&#8217;s see how.</p>
<p>First, we obviously need to install all the software we will need.</p>
<p><span id="more-148"></span></p>
<p>Make sure you have make, g++, perl-URI and perl-libwww-perl installed (or liburi-perl and libwww-perl on debian based distros).</p>
<p>1) Sproxy:</p>
<pre class="brush: bash; title: ; notranslate">wget ftp://ftp.joedog.org/pub/sproxy/sproxy-latest.tar.gz
tar xzvf  sproxy-latest.tar.gz
./configure
make
make install</pre>
<p>2) Siege:</p>
<pre class="brush: bash; title: ; notranslate">wget ftp://ftp.joedog.org/pub/siege/siege-latest.tar.gz
tar xzvf  siege-latest.tar.gz
./configure
make
make install</pre>
<p>We know need to collect some urls using Sproxy.</p>
<p>Launch sproxy and take note of the port it binded to, we will use this information to connect to it as a standard proxy. Here it comes the cool thing, every url we will visit through sproxy will be written to a file in a format Siege understands.</p>
<p>The url list will be written in ~/urls.txt, you can override this using he flag -o: for example:</p>
<pre class="brush: bash; title: ; notranslate">sproxy -o /home/user/benchmark/urls.txt</pre>
<p>Collecting urls manually using a browser (e.g: Firefox) could be a long process, especially for a forum or for websites with a lot of content. Wouldn&#8217;t it be cool to let an automatic tool do the hard work for us? Of course, so wget comes to the rescue!<br />
Yes, you heard (read?) right, wget is a really powerful program even if you&#8217;ve always used it for downloading files only, so here&#8217;s an example of how we can crawl a website through sproxy using wget:</p>
<pre class="brush: bash; title: ; notranslate">wget -r -o verbose.txt -l 0 -t 1 --spider -w 1 -e robots=on -e &quot;http_proxy = http://127.0.0.1:9001&quot; &quot;http://www.example.com&quot;
</pre>
<p>-w: specify the seconds to wait between requests to avoid overloading the webserver<br />
-l: the number of maximum levels to descend, 0 means infinite.</p>
<p>For other options such as excluding some directories/file extensions please refer to &#8220;man wget&#8221;.</p>
<p>After some minutes/hours of crawling we should have a lot of urls in our sproxy file, let&#8217;s filter out all the duplicates:</p>
<pre class="brush: bash; title: ; notranslate">sort -u -o uniq_urls.txt urls.txt</pre>
<p>Finally, we can launch the actual siege test that will simulate real users visits across the urls we previously collected:</p>
<pre class="brush: bash; title: ; notranslate">siege -v -c 50 -i -t 3M -f uniq_urls.txt -d 10</pre>
<p>-v will give you more information of what siege is doing during the test.<br />
-c specifies the number of total users simulated.<br />
-i indicates to hit the urls in a random fashion.<br />
-t specify the running time of siege, you can use S, M or H<br />
-f  is pretty obvious.<br />
-d specify the maximum delay between a simulated user requests.</p>
<p>Maybe the last one is a little tricky to understand, I&#8217;ll try to explain it better: siege in order to simulate a real users load randomize the time wait between page requests of a user, so -d indicates the maximum seconds between A user&#8217;s &#8220;clicks&#8221;. 30 seconds is a good value if you think of users behavior on a website, but of course you can set whatever you think is appropriate.</p>
<p>That&#8217;s all, feel free to drop a comment if you are having troubles, there&#8217;s something wrong with the article or you just want to say thanks.</p>
<div id="tweetbutton148" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fsimulate-real-users-load-on-a-webserver-using-siege-and-sproxy%2F&amp;via=andreausu&amp;text=Simulate%20real%20users%20load%20on%20a%20webserver%20using%20Siege%20and%20Sproxy&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fsimulate-real-users-load-on-a-webserver-using-siege-and-sproxy%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/NniumwnpGgY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/simulate-real-users-load-on-a-webserver-using-siege-and-sproxy/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://usu.li/blog/simulate-real-users-load-on-a-webserver-using-siege-and-sproxy/</feedburner:origLink></item>
		<item>
		<title>Accessing Miso API: a sample PHP application</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/XcmzlOaSyds/</link>
		<comments>http://usu.li/blog/accessing-miso-api-a-sample-php-application/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 12:10:18 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[miso]]></category>
		<category><![CDATA[oauth]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=131</guid>
		<description><![CDATA[Miso recently introduced the ability to access their data through API which is really great, I&#8217;m already using it in production on Italiansubs.net. The documentation (that you should definitely read) [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Miso" href="http://gomiso.com" target="_blank">Miso</a> recently introduced the ability to access their data through API which is really great, I&#8217;m already using it in production on <a title="Italiansubs.net" href="http://www.italiansubs.net" target="_blank">Italiansubs.net</a>.</p>
<p>The <a title="Documentation" href="http://gomiso.com/developers/getting_started" target="_blank">documentation</a> (that you should definitely read) is well written and  easy to follow if you have any experience in working with json API and OAuth, but if you haven&#8217;t, and you don&#8217;t know Ruby (the programming language used for their sample application) it&#8217;s possible to find it tricky.</p>
<p>So, here&#8217;s the sample PHP application:<br />
<span id="more-131"></span><br />
First, install the <a title="PECL OAuth library" href="http://pecl.php.net/package/oauth" target="_blank">PECL OAuth library</a></p>
<pre class="brush: bash; title: ; notranslate">pecl install oauth</pre>
<p>And add the extension to your php.ini file</p>
<pre class="brush: bash; title: ; notranslate">extension=oauth.so</pre>
<p>The first file is the configuration file (misoconfig.php)</p>
<pre class="brush: php; title: ; notranslate">define('OAUTH_CONSUMER_KEY',&quot;yourconsumerkey&quot;);
define('OAUTH_CONSUMER_SECRET',&quot;yourconsumersecret&quot;);
define('OAUTH_REQUEST_TOKEN_API', 'https://gomiso.com/oauth/request_token');
define('OAUTH_ACCESS_TOKEN_API', 'https://gomiso.com/oauth/access_token');
define('OAUTH_AUTHORIZE_API', 'https://gomiso.com/oauth/authorize');
define('OAUTH_TMP_DIR', function_exists('sys_get_temp_dir') ? sys_get_temp_dir() : realpath($_ENV[&quot;TMP&quot;]));
define('MISO_USER_AGENT', 'youruseragent');</pre>
<p>The next file requests a token, saves it in a tmp file and redirects the user to Miso for the authentication, if the user allows your application, he will be redirected to the callback url</p>
<pre class="brush: php; title: ; notranslate">require 'misoconfig.php';
$req_url = OAUTH_REQUEST_TOKEN_API;
try {
$o = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,
OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_FORM);
$o-&amp;gt;enableDebug();
$resp = $o-&amp;gt;getRequestToken($req_url, &quot;http://www.yourwebsite.com/callback.php&quot;);
} catch(OAuthException $E) {
echo &quot;Response: &quot;. $E-&amp;gt;lastResponse . &quot;\n&quot;;
}
file_put_contents(&quot;/tmp/last_request&quot;,$resp['oauth_token'].&quot;\n&quot;.
$resp['oauth_token_secret'].&quot;\n&quot;);
print_r ($resp);
header(&quot;Location: &quot;.OAUTH_AUTHORIZE_API.&quot;?oauth_token=&quot;.$resp['oauth_token']);</pre>
<p>The last file (callback.php) lets us acquire the access token by using the previous request token and the oauth verifier:</p>
<pre class="brush: php; title: ; notranslate">require 'misoconfig.php';
$acc_url = OAUTH_ACCESS_TOKEN_API;
list($token,$secret) = file('/tmp/last_request');
$token = trim($token);
$secret = trim($secret);
$verifier = $_GET['oauth_verifier'];
try {
$o = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,
OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_URI);
$o-&amp;gt;enableDebug();
$o-&amp;gt;setToken($token,$secret);
$resp = $o-&amp;gt;getAccessToken($acc_url, NULL, $verifier);
file_put_contents(&quot;/tmp/access_token.txt&quot;,serialize($resp));
} catch(OAuthException $E) {
echo &quot;Response: &quot;. $E-&amp;gt;lastResponse . &quot;\n&quot;;
}
print_r($resp);</pre>
<p>We&#8217;re done! We can now access Miso&#8217;s API using the access token, you can test it with something like this:</p>
<pre class="brush: php; title: ; notranslate">try {
$oauth = new OAuth(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauth-&amp;gt;setToken($oauth_token,$oauth_token_secret);
$oauth-&amp;gt;fetch('http://gomiso.com/api/oauth/v1/users/show.json', null, OAUTH_HTTP_METHOD_GET, array('User-Agent'=&amp;gt;''.MISO_USER_AGENT.''));
$response_info = $oauth-&amp;gt;getLastResponseInfo();
header(&quot;Content-Type: {$response_info[&quot;content_type&quot;]}&quot;);
echo $oauth-&amp;gt;getLastResponse();
} catch(OAuthException $E) {
echo &quot;Exception caught!\n&quot;;
echo &quot;Response: &quot;. $E-&amp;gt;lastResponse . &quot;\n&quot;;
}</pre>
<p>Please note that this is just an example that should let you understand how to access Miso API, it won&#8217;t work out of the box just by uploading this code snippets into your FTP.</p>
<div id="tweetbutton131" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Faccessing-miso-api-a-sample-php-application%2F&amp;via=andreausu&amp;text=Accessing%20Miso%20API%3A%20a%20sample%20PHP%20application&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Faccessing-miso-api-a-sample-php-application%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/XcmzlOaSyds" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/accessing-miso-api-a-sample-php-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://usu.li/blog/accessing-miso-api-a-sample-php-application/</feedburner:origLink></item>
		<item>
		<title>How to upgrade to Ubuntu Server 10.10 (Maverick Meerkat)</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/XT3fklpF-W4/</link>
		<comments>http://usu.li/blog/how-to-upgrade-to-ubuntu-server-10-10-maverick-meerkat/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 17:39:41 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=123</guid>
		<description><![CDATA[The new release of Ubuntu is out! Anyway, if you&#8217;re running Ubuntu Server on a production system, I would recommend you to stick with the LTS version (10.04 Lucid Lynx). [...]]]></description>
			<content:encoded><![CDATA[<p>The new release of Ubuntu is out! Anyway, if you&#8217;re running Ubuntu Server on a production system, I would recommend you to stick with the LTS version (10.04 Lucid Lynx).</p>
<p>Here&#8217;s how to perform the upgrade in 3 simple steps:</p>
<p>First, make sure you have the <strong>update-manager-core </strong>package installed:</p>
<pre class="brush: bash; title: ; notranslate">sudo apt-get install update-manager-core</pre>
<p>Now we use nano to edit <strong>/etc/update-manager/release-upgrades</strong> and set <strong>Prompt=normal</strong></p>
<pre class="brush: bash; title: ; notranslate">nano /etc/update-manager/release-upgrades</pre>
<p>Last step, launch the upgrade tool and follow the instructions:</p>
<pre class="brush: bash; title: ; notranslate">sudo do-release-upgrade -d</pre>
<div id="tweetbutton123" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-upgrade-to-ubuntu-server-10-10-maverick-meerkat%2F&amp;via=andreausu&amp;text=How%20to%20upgrade%20to%20Ubuntu%20Server%2010.10%20%28Maverick%20Meerkat%29&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-upgrade-to-ubuntu-server-10-10-maverick-meerkat%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/XT3fklpF-W4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/how-to-upgrade-to-ubuntu-server-10-10-maverick-meerkat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://usu.li/blog/how-to-upgrade-to-ubuntu-server-10-10-maverick-meerkat/</feedburner:origLink></item>
		<item>
		<title>How to run a cron job every X seconds</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/VgRppq3h-1o/</link>
		<comments>http://usu.li/blog/how-to-run-a-cron-job-every-x-seconds/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 10:02:05 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cron]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=116</guid>
		<description><![CDATA[There&#8217;s a really simple way for doing this directly in crontab: putting the process to sleep. Let&#8217;s see how: imagine you need to run a PHP script every 10 seconds [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a really simple way for doing this directly in crontab: putting the process to sleep.</p>
<p>Let&#8217;s see how: imagine you need to run a PHP script every 10 seconds to check whether a webiste is responding, here&#8217;s what you would need to put in crontab:</p>
<pre class="brush: bash; title: ; notranslate">* * * * * /usr/local/bin/php /var/www/uptime.php
* * * * * sleep 10; /usr/local/bin/php /var/www/uptime.php
* * * * * sleep 20; /usr/local/bin/php /var/www/uptime.php
* * * * * sleep 30; /usr/local/bin/php /var/www/uptime.php
* * * * * sleep 40; /usr/local/bin/php /var/www/uptime.php
* * * * * sleep 50; /usr/local/bin/php /var/www/uptime.php</pre>
<p>What we&#8217;re doing here, is starting 6 processes altogether every minute with progressive sleep times and that results in running the PHP script every 10 seconds. As simple as that.</p>
<div id="tweetbutton116" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-run-a-cron-job-every-x-seconds%2F&amp;via=andreausu&amp;text=How%20to%20run%20a%20cron%20job%20every%20X%20seconds&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-run-a-cron-job-every-x-seconds%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/VgRppq3h-1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/how-to-run-a-cron-job-every-x-seconds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://usu.li/blog/how-to-run-a-cron-job-every-x-seconds/</feedburner:origLink></item>
		<item>
		<title>How to automatically update your FeedBurner RSS using cURL</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/zBnfJ4b_rPg/</link>
		<comments>http://usu.li/blog/how-to-automatically-update-your-feedburner-rss-using-curl/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 09:13:08 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[FeedBurner]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[RSS Feed]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=100</guid>
		<description><![CDATA[FeedBurner is a pretty cool service that provides insights and many other useful information about the RSS Feed of a website, though if you need your users to be notified [...]]]></description>
			<content:encoded><![CDATA[<p><a title="FeedBurner" href="http://feedburner.google.com" target="_blank">FeedBurner</a> is a pretty cool service that provides insights and many other useful information about the RSS Feed of a website, though if you need your users to be notified immediately after a new item is posted on the website you&#8217;ll find that there is a nasty limitation in place: the feed is only updated every 30 minutes.</p>
<p>Fortunately FeedBurner also provides a <a title="FeedBurner Ping Service" href="http://feedburner.google.com/fb/a/ping" target="_blank">ping service</a> that let you manually update your RSS Feed; but visiting a website every time you need to update your feed isn&#8217;t very practical, instead we can use cURL to do this automatically every time we publish a new article or something.</p>
<p>Here&#8217;s the PHP code (you need to make sure that your hosting has cURL enabled):</p>
<pre class="brush: php; title: ; notranslate">$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, 'http://feedburner.google.com/fb/a/pingSubmit');
curl_setopt($ch2, CURLOPT_POST, 1);
curl_setopt($ch2, CURLOPT_POSTFIELDS, 'bloglink=http://www.example.com');
$result = curl_exec($ch2);
curl_close($ch2);
</pre>
<p>You need to place this right after the code that publishes a new item on your website, so that the RSS Feed is immediately updated with the new articles (or whatever you are publishing).</p>
<p>Another way to do this is by putting the code in a cronjob and run it every X minutes, but use this only if you can&#8217;t get  the other method working, it&#8217;s way better.</p>
<p>Here&#8217;s the code to use cURL directly from the command line (use this if you are planning to go with the cronjob method):</p>
<pre class="brush: bash; title: ; notranslate">curl -d 'bloglink=http://www.example.com' http://feedburner.google.com/fb/a/pingSubmit</pre>
<p>Also you don&#8217;t need to provide the full RSS Feed URL, the website base URL will do just fine.</p>
<div id="tweetbutton100" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-automatically-update-your-feedburner-rss-using-curl%2F&amp;via=andreausu&amp;text=How%20to%20automatically%20update%20your%20FeedBurner%20RSS%20using%20cURL&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fhow-to-automatically-update-your-feedburner-rss-using-curl%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/zBnfJ4b_rPg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/how-to-automatically-update-your-feedburner-rss-using-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://usu.li/blog/how-to-automatically-update-your-feedburner-rss-using-curl/</feedburner:origLink></item>
		<item>
		<title>Benchmark: libmysql vs mysqlnd</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/OFHmMQj_hC4/</link>
		<comments>http://usu.li/blog/benchmark-libmysql-vs-mysqlnd/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 18:04:35 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[Benchmarks]]></category>
		<category><![CDATA[apachebench]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[libmysql]]></category>
		<category><![CDATA[libmysqlclient]]></category>
		<category><![CDATA[mysqlnd]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[pidof]]></category>
		<category><![CDATA[pmap]]></category>
		<category><![CDATA[ram]]></category>
		<category><![CDATA[requests/s]]></category>
		<category><![CDATA[vmware]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=24</guid>
		<description><![CDATA[A few days ago I found out about the existence of the MySQL Native Driver (mysqlnd) that has been introduced in php 5.3, it is a replacement for libmysqlclient and [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I found out about the existence of  the MySQL Native Driver (mysqlnd) that has been introduced in php 5.3, it is a replacement for libmysqlclient and it is licensed under the PHP license, therefore avoiding the need of the <a title="FOSS Exception" href="http://www.mysql.com/about/legal/licensing/foss-exception/" target="_blank">FOSS License Exception</a>.</p>
<p>The purpose of this article isn&#8217;t explaining what mysqlnd is and what it does, for that you can start by reading the <a title="php mysqlnd" href="http://forge.mysql.com/wiki/PHP_MYSQLND" target="_blank">official documentation</a> and <a title="php mysqlnd blog post" href="http://blog.felho.hu/what-is-new-in-php-53-part-3-mysqlnd.html" target="_blank">this nice blog post</a>.</p>
<p>I did these benchmarks mostly because I couldn&#8217;t find any proper comparison between the two drivers and I wanted to know which driver I should be using on all the servers I manage (performance-wise), I then figured that making this public could be useful to someone else, so here it is.</p>
<p><span id="more-24"></span></p>
<p><strong>Test System</strong><br />
VMware Virtual Machine (VMware Workstation 7.1.0 build-261024)<br />
Host RAM: 8GB<br />
Host CPU: Intel Q8400<br />
Host OS: Windows 7 Enterprise x64<br />
VM RAM: 4GB<br />
VM CPU: 1 CPU &#8211; 4 Cores<br />
VM OS: Debian 5 x64</p>
<p><strong>Software Utilized</strong><br />
nginx 0.7.67<br />
php-fpm (the one included in php 5.3.3)<br />
MySQL 5.5.5-m3 (with the malloc lib provided by google-perftools)<br />
APC 3.1.4-dev<br />
ApacheBench 2.3 (installed on another PC, connected to the Host with gbit ethernet)<br />
Wordpress 3.0.1</p>
<p><strong><span style="font-size: x-small;">nginx compile options</span></strong><span style="font-size: x-small;">: ./configure &#8211;sbin-path=/usr/local/sbin &#8211;with-http_ssl_module &#8211;without-mail_pop3_module &#8211;without-mail_imap_module &#8211;without-mail_smtp_module &#8211;with-http_stub_status_module</span></p>
<p><strong><span style="font-size: x-small;">PHP compile options (mysqlnd)</span></strong><span style="font-size: x-small;">: ./configure &#8211;enable-fpm &#8211;with-mcrypt &#8211;with-zlib &#8211;enable-mbstring &#8211;with-openssl &#8211;with-mysql=mysqlnd &#8211;with-mysql-sock &#8211;with-pdo-mysql=mysqlnd &#8211;with-gd &#8211;with-jpeg-dir=/usr/lib &#8211;with-freetype-dir=/usr/local/lib/ &#8211;enable-gd-native-ttf &#8211;with-curl=/usr/include/curl &#8211;enable-soap</span></p>
<p><strong><span style="font-size: x-small;">PHP compile options (libmysqlclient)</span></strong><span style="font-size: x-small;">: ./configure &#8211;enable-fpm &#8211;with-mcrypt &#8211;with-zlib &#8211;enable-mbstring &#8211;with-openssl &#8211;with-mysql &#8211;with-mysql-sock &#8211;with-pdo-mysql &#8211;with-gd &#8211;with-jpeg-dir=/usr/lib &#8211;with-freetype-dir=/usr/local/lib/ &#8211;enable-gd-native-ttf &#8211;with-curl=/usr/include/curl &#8211;enable-soap</span></p>
<p><strong><span style="font-size: x-small;">MySQL compile options</span></strong><span style="font-size: x-small;">: ./configure &#8211;with-plugins=innobase</span></p>
<p>The first test measures the number of requests per second targeting a fresh install of WordPress that can be handled using the two different drivers. The benchmarking tool used is ApacheBench launched through <a title="ab script" href="http://www.usuelli.net/apachebench-script/" target="_blank">this script</a>, as you can see the script registers the results of 5 different runs, I then calculated the average.</p>
<p>Amount of <strong>CPU utilized</strong> by <strong>3 concurrent requests</strong>: <strong>~75%</strong><br />
Amount of <strong>CPU utilized</strong> by <strong>100 concurrent requests</strong>: <strong>100%</strong></p>
<p style="text-align: center;"><strong><span style="color: #3366ff;">libmysqlclient</span></strong></p>
<table border="0" cellspacing="10" align="center">
<tbody>
<tr>
<td>APC enabled<br />
Concurrency level: 3<br />
Total number of requests: 1250<br />
<strong>Average r/s: </strong><strong><span style="color: #339966;">136,012</span></strong></td>
<td>APC enabled<br />
Concurrency level: 100<br />
Total number of requests: 2500<br />
<strong>Average r/s: </strong><strong><span style="color: #339966;">159,882</span></strong></td>
</tr>
<tr>
<td>APC disabled<br />
Concurrency level: 3<br />
Total number of requests: 1250<br />
<strong>Average r/s: </strong><strong><span style="color: #ff0000;">28,84</span></strong></td>
<td>APC disabled<br />
Concurrency level: 100<br />
Total number of requests: 2500<br />
<strong>Average r/s: </strong><strong><span style="color: #ff0000;">35,002</span></strong></td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><span style="color: #339966;"><strong><span style="color: #3366ff;">mysqlnd</span></strong></span></p>
<table border="0" cellspacing="10" align="center">
<tbody>
<tr>
<td>APC enabled<br />
Concurrency level: 3<br />
Total number of requests: 1250<br />
<strong>Average r/s: </strong><strong><span style="color: #ff0000;">133,166</span></strong></td>
<td>APC enabled<br />
Concurrency level: 100<br />
Total number of requests: 2500<br />
<strong>Average r/s: </strong><strong><span style="color: #ff0000;">158,262</span></strong></td>
</tr>
<tr>
<td>APC disabled<br />
Concurrency level: 3<br />
Total number of requests: 1250<br />
<strong>Average r/s: </strong><strong><span style="color: #339966;">29,748</span></strong></td>
<td>APC disabled<br />
Concurrency level: 100<br />
Total number of requests: 2500<br />
<strong>Average r/s: </strong><strong><span style="color: #339966;">37,212</span></strong></td>
</tr>
</tbody>
</table>
<p>As you can see with APC enabled libmysqlclient can handle more r/s than mysqlnd, but if you disable APC the behavior completely changes.<br />
Comparing only the pure numbers is not very useful, so I converted the results in percentage:</p>
<p>Gain achieved by using <strong>libmysqlclient over mysqlnd</strong> with <strong>APC enabled</strong> (3 concurrent requests): <strong>2,09%</strong><br />
Gain achieved by using <strong>libmysqlclient over mysqlnd</strong> with <strong>APC enabled</strong> (100 concurrent requests): <strong>1,01%</strong><br />
Gain achieved by using <strong>mysqlnd over libmysqlclient</strong> with <strong>APC disabled</strong> (3 concurrent requests):  <strong>3,05%</strong><br />
Gain achieved by using <strong>mysqlnd over libmysqlclient</strong> with <strong>APC disabled</strong> (100 concurrent requests): <strong>5,94%</strong></p>
<p>So if you only care about pure performances and you are using APC you should probably stick with libmysqlclient, but if you aren&#8217;t using APC or you care about RAM consumption too, you should read on.</p>
<p>Now, imagine you need to host a php/mysql based website on a VPS that has only 128MB of RAM, what would be the best driver to choose (RAM consumption-wise)?</p>
<p>For this test I used 20 php-fpm child and I measured the RAM consumption after 30 seconds of multiple requests generated by ApacheBench, this is the simple script I made to register the exact amount of RAM used by every PHP process:</p>
<pre class="brush: bash; title: ; notranslate">sleep 30
pmap $(pidof php-fpm) | grep total | awk '{ print $2 }' | sed s/.$//</pre>
<p>In order to get the most accurate results possible I run all tests three times and then I calculated the average:</p>
<p style="text-align: center;"><span style="color: #3366ff;"><strong>libmysqlclient</strong></span></p>
<table border="0" cellspacing="10" align="center">
<tbody>
<tr>
<td>APC enabled<br />
Total RAM Consumption (20 child): <span style="color: #ff0000;">78,94 MB</span><br />
Single process average RAM Consumption: <span style="color: #ff0000;">78,94 MB</span></td>
<td>APC disabled<br />
Total RAM Consumption (20 child): <span style="color: #ff0000;">287,85 MB</span><br />
Single process average RAM Consumption: <span style="color: #ff0000;">14,38 MB</span></td>
</tr>
</tbody>
</table>
<p style="text-align: center;"><strong><span style="color: #3366ff;">mysqlnd</span></strong></p>
<table border="0" cellspacing="10" align="center">
<tbody>
<tr>
<td>APC enabled<br />
Total RAM Consumption (20 child): <span style="color: #339966;">78,62 MB</span><br />
Single process average RAM Consumption: <span style="color: #339966;">78,62 MB</span></td>
<td>APC disabled<br />
Total RAM Consumption (20 child): <span style="color: #339966;">284,19 MB</span><br />
Single process average RAM Consumption: <span style="color: #339966;">14,21 MB</span></td>
</tr>
</tbody>
</table>
<p>RAM saved by using <strong>mysqlnd over libmysqlclient</strong> with <strong>APC enabled</strong>: <strong>0,41%</strong><br />
RAM saved by using <strong>mysqlnd over libmysqlclient</strong> with <strong>APC disabled</strong>: <strong>1,18%</strong></p>
<p>Oh well, if your biggest concern is RAM occupation you should definitely use mysqlnd.</p>
<p>Of course which MySQL driver you use is only a tiny part of what can be changed on a server in order to achieve better performance, but when it comes to optimizing things, every little detail counts.</p>
<div id="tweetbutton24" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fbenchmark-libmysql-vs-mysqlnd%2F&amp;via=andreausu&amp;text=Benchmark%3A%20libmysql%20vs%20mysqlnd&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fbenchmark-libmysql-vs-mysqlnd%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/OFHmMQj_hC4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/benchmark-libmysql-vs-mysqlnd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://usu.li/blog/benchmark-libmysql-vs-mysqlnd/</feedburner:origLink></item>
		<item>
		<title>ApacheBench Script</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/UonunYL9yng/</link>
		<comments>http://usu.li/blog/apachebench-script/#comments</comments>
		<pubDate>Mon, 02 Aug 2010 16:59:58 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[Benchmarks]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[apachebench]]></category>
		<category><![CDATA[benchmark]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=59</guid>
		<description><![CDATA[Quoting from Apache Benchmark official website: ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your [...]]]></description>
			<content:encoded><![CDATA[<p>Quoting from <a title="apachebench official website" href="http://httpd.apache.org/docs/2.0/programs/ab.html" target="_blank">Apache Benchmark official website</a>:</p>
<blockquote><p>ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs.</p></blockquote>
<p>In order to make sure that a benchmark involving the use of ApacheBench is run without any distortion due to, for example, wait times that could lead to cache expiration I needed a very simple bash script, so here it is:</p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash
NUM=1250
CONC=3
SLEEP=15
FILENAME=Benchmark
URL=http://www.example.com/
echo &quot;a started&quot;
ab -n $NUM -c $CONC $URL &gt; $FILENAME-$CONC-$NUM-a.txt
echo &quot;a completed&quot;
sleep $SLEEP
echo &quot;b started&quot;
ab -n $NUM -c $CONC $URL &gt; $FILENAME-$CONC-$NUM-b.txt
echo &quot;b completed&quot;
sleep $SLEEP
echo &quot;c started&quot;
ab -n $NUM -c $CONC $URL &gt; $FILENAME-$CONC-$NUM-c.txt
echo &quot;c completed&quot;
sleep $SLEEP
echo &quot;d started&quot;
ab -n $NUM -c $CONC $URL &gt; $FILENAME-$CONC-$NUM-d.txt
echo &quot;d completed&quot;
sleep $SLEEP
echo &quot;e started&quot;
ab -n $NUM -c $CONC $URL &gt; $FILENAME-$CONC-$NUM-e.txt
echo &quot;e completed&quot;
exit 0</pre>
<div id="tweetbutton59" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fapachebench-script%2F&amp;via=andreausu&amp;text=ApacheBench%20Script&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fapachebench-script%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/UonunYL9yng" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/apachebench-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://usu.li/blog/apachebench-script/</feedburner:origLink></item>
		<item>
		<title>Di nuovo online!</title>
		<link>http://feedproxy.google.com/~r/Usus-Blog/~3/nAwLVUP9NLs/</link>
		<comments>http://usu.li/blog/di-nuovo-online/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 21:50:22 +0000</pubDate>
		<dc:creator>Usu</dc:creator>
				<category><![CDATA[Announcements]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[cms]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[serendipity]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.usuelli.net/?p=9</guid>
		<description><![CDATA[Era un po&#8217; di tempo che avevo intenzione di rimettere su il blog personale, tuttavia volevo evitare di farlo utilizzando WordPress visto che è scritto senza rispettare le più basilari [...]]]></description>
			<content:encoded><![CDATA[<p>Era un po&#8217; di tempo che avevo intenzione di rimettere su il blog personale, tuttavia volevo evitare di farlo utilizzando WordPress visto che è scritto senza rispettare le più basilari regole per una programmazione <del datetime="2010-07-29T21:32:29+00:00">corretta</del> quantomeno sensata.</p>
<p>Cosa scegliere quindi? Sembra facile, ma non sono poi molti i CMS PHP creati specificamente per l&#8217;amministrazione di un blog. In attesa che <a href="http://twitter.com/AntoAngelino" target="_blank">Antonio</a> sviluppi la <a href="http://www.hostingtalk.it/forum/io-programmo/14914-piattaforma-di-blogging-quali-feature-vorreste.html" target="_blank">piattarforma di blogging ideale</a> mi sono messo alla ricerca di qualcosa che facesse al mio caso e, dopo essermi imbattuto in cessi intervallati da CMS aggiornati al 2005, pensavo di averlo trovato: <a href="http://s9y.org" target="_blank">Serendipity</a>.</p>
<p>Beh inutile dire che è stato un gigantesco FAIL: dopo averci perso una giornata a preparare il tutto, installare i plugin necessari (ne servono un po&#8217; dato che le funzioni &#8220;out of the box&#8221; sono davvero basilari), modificare un po&#8217; il tema, ed altre cosucce; vado finalmente a spostare i files nella root del sito per mettere online il tutto (avevo installato il CMS in una sottocartella per i test), modifico di conseguenza la configurazione e&#8230; puff! Non l&#8217;avessi mai fatto!</p>
<p>Ecco il simpatico errore apparso:</p>
<pre class="brush: plain; title: ; notranslate">serendipity error: could not include /path/serendipity_config_local.inc.php - exiting.
Please create the file yourself or check permissions</pre>
<p>Inutile dire che il file c&#8217;era, aveva i permessi giusti, ecc. Dopo altro tempo perso tra infinite prove e googlate inutili (sembra che questo problema, una volta presentatosi, nessuno sia mai riuscito a risolverlo) ho optato per un bel &#8220;rm -r serendipity/&#8221; e ho, a malincuore, (re)installato WordPress.</p>
<p>Ecco, avevo bisogno di un primo post per mettere quantomeno online il tutto, pur essendo io il re dell&#8217;incostanza e il peggior nemico della grafica cercherò di lavorare al blog per renderlo decente e addirittura(!) pubblicare qualche contenuto interessante.</p>
<div id="tweetbutton9" class="tw_button" style="float:right;margin-left:10px;"><a href="http://twitter.com/share?url=http%3A%2F%2Fusu.li%2Fblog%2Fdi-nuovo-online%2F&amp;via=andreausu&amp;text=Di%20nuovo%20online%21&amp;related=andreausu&amp;lang=en&amp;count=horizontal&amp;counturl=http%3A%2F%2Fusu.li%2Fblog%2Fdi-nuovo-online%2F" class="twitter-share-button"  style="width:55px;height:22px;background:transparent url('http://usu.li/blog/wp-content/plugins/wp-tweet-button/tweetn.png') no-repeat  0 0;text-align:left;text-indent:-9999px;display:block;">Tweet</a></div><img src="http://feeds.feedburner.com/~r/Usus-Blog/~4/nAwLVUP9NLs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://usu.li/blog/di-nuovo-online/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://usu.li/blog/di-nuovo-online/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using apc
Database Caching using apc
Object Caching 2099/2238 objects using apc

Served from: usu.li @ 2011-07-26 16:13:41 -->

