So I have mentioned the
BLOB Streaming Project quite a lot lately, and for good reason! Paul has recently released an alpha version of the engine itself, called MyBS. I took some time last weekend to benchmark it's performance and thought I would share my result. Keep in mind, these are rather crude, but I think they do get the point across.
For the tests I used a slightly modified version
StuffDawg since it already stores images inside the database. Oddly enough, I found a few bugs with StuffDawg that I was able to patch up and will be releasing an update soon.
So before I explain things, here is the juicy stuff - the results:
tim@filedawg ~/tmp $ time wget --quiet http://stuffdawg/image.php?itemid=20
real 0m0.767s
user 0m0.000s
sys 0m0.012s
tim@filedawg ~/tmp $ time wget --quiet http://stuffdawg:8080/StuffDawg/Images/image/itemid=20
real 0m0.024s
user 0m0.008s
sys 0m0.008s
tim@filedawg ~/tmp $ time wget --quiet http://stuffdawg/TravelingMonoliths.jpg
real 0m0.017s
user 0m0.004s
sys 0m0.012s
The idea was to grab the same image using three different methods. The first used the common PHP approach, which calls for using a PHP script that pulls the file from the database and presents it to the browser with the correct MIME types, etc. The second used the MyBS engine to grab the file, and the third grabbed the file off the file system using a GET. For these tests, I used the source distributions of MyBS 1.0-alpha, PBXT 0.9.87-beta, and MySQL 5.1.19. For the PHP part of the test, I used PHP 5.2.1 and Apache 2.0.58, both of which were compiled from source (as Gentoo ebuilds). The machine was not amazingly fast sporting an Athlon 1.2Ghz with 512MB of RAM.
Even so, you can see that the first test took .779 second total, while the second took only 0.032 seconds and was faster than grabbing the file directly (although, to be fair, the accuracy of the time command could come into play there)! That represents a 24x improvement over using PHP! Granted, a faster processor would shorten the time it would have taken to display the image using PHP, but that is not the real point here.
The point is that by using the MyBS engine, you eliminate the overhead incurred by having to use PHP to serve the content from the database. Not only that, but serving the content is hugely simple! It is too soon to tell, of course, if this is going to be how you would go about this in production, however. Paul
mentions that there is currently no security on-top, meaning you would not want to open this up to the world as-is, although you could potentially use ProxyPass in Apache to sit in-between. I think ultimately Paul has greater plans in mind as well, such as APIs for things like PHP to hook into the MyBS engine directly.
All in all, even though the BlobStreaming project is currently in alpha state, it looks like an excellent start and I really do think that this will change the way people start developing their applications. You can rest assured that StuffDawg will certainly have options to support MyBS and the PBXT engine. And I am already thinking about how I can convert my own Photo Album and Music sections to make use of blobs.
Really really cool stuff!
Tags: