MySQL Conference 2009

Friday, April 24, 2009

I've just returned from the MySQL Conference 2009 in Santa Clara where CodeFutures launched the beta of dbShards Cloud Edition. It was great to see such a good turnout at the show (I heard that there were between 1,500 and 2,000 attendees) despite the state of the economy. It was also great to see how many companies are either implementing sharding or considering sharding for their applications. There seems to be much greater awareness of sharding than there was just one year ago and people I met understood that a shared-nothing approach offers the best possible performance and scalability. The one common concern about adopting sharding is that it introduces complexity into the application, but using a packaged solution such as dbShards this is much less of an issue.

CodeFutures @ MySQL Conference 2009

Tuesday, April 14, 2009

CodeFutures will be exhibiting at this year's MySQL conference. Visit us on the exhibition floor Tuesday through Thursday next week to see a demonstration of dbShards.

Ruby/Webrick File upload using multipart/form-data

Sunday, January 25, 2009

One of the challenges I'm running into with Ruby is that there isn't the same level of reference documentation as there is in Java. It took me far too long to work out how to implement HTTP multipart file upload in Ruby so I'm posting the code here in the hope that it is useful for others.

The following Ruby source is for a web server with a file upload servlet that accepts multpart/form-data file uploads.

#!/usr/local/bin/ruby
require 'webrick'
require 'stringio'
include WEBrick

s = HTTPServer.new( :Port => 8090 )

class FileUploadServlet < HTTPServlet::AbstractServlet
def do_POST(req, res)
filedata= req.query["filename"]

f = File.open("foo.out", "wb")
f.syswrite req.filedata
f.close

puts "Saved file OK"
end
end
s.mount("/upload", FileUploadServlet)

trap("INT"){ s.shutdown }
s.start


This is the HTML form to test this servlet with


<form action="http://localhost:8090/upload" method="POST" enctype="multipart/form-data">
File: <input type="file" name="filename"><br/>
<input type="submit" value="Upload">
</form>

Labels:


FireStorm now supports Ruby

Wednesday, January 21, 2009

FireStorm/DAO 4.0.1 includes a Ruby DAO code generator for MySQL (using the mysql-ruby library to interact with the database). To see sample generated Ruby DAO code, take a look at this MySQL-Ruby Tutorial.

The new release is available to download here.

Labels:


Python first impressions

Wednesday, January 14, 2009

Over the past couple of months I have started developing in Python and to a lesser degree so far, Ruby. I have mostly only used strongly typed compiled languages, namely C++ and Java throughout my career and have often resisted doing anything in scripting languages that I felt I could do in Java or C++, mostly because I'm already proficient in those languages and I rarely have too much time for non-essential learning curves.

However, I am now building some tooling for dbShards, our database sharding, replication, and failover solution, using Python. The main reason for choosing Python over Java is that we wanted a lightweight framework that makes it easy to monitor and control operating system processes on remote servers. Python was recommended to me by a friend (thanks, Paul!) and so far it looks like a pretty good choice, although I'm sure Ruby would also have been a good choice for this project.

Both Python and Ruby are object oriented to varying degrees but both allow good object oriented design and implementation making it easy for Java developers to pick up the language. The Python syntax has a couple of things that don't feel too natural, such as constructors being called __init__() and the fact that all non-static methods on a class must have a 'self' parameter rather than having a built in 'this' attribute as in Java. Neither of these is really a problem at all and they soon start to feel natural enough. The only real bugbear I have have with the Python language itself is the indentation syntax - Python purely relies on indentation (tabs and spaces) in the code to determine nesting rather than using curly braces or any other form of begin/end syntax. As a result, I find myself constantly switching between text editors and vi to fix indenting issues at the moment. I will have to spend some time researching IDEs for Python (so far I have been using the IntelliJ plugin, the PyDev plugin for Eclipse, and TextMate and none of them seem great at preserving the indents correctly). If anyone has any recommendations for Python tools please let me know.

Those issues aside, Python is a nice language and easy to learn. Most tasks can be implemented faster than the same tasks using Java, but not to the degree that many report (I have seen many claims of 5-10x productivity gains over Java and these might be true for someone who is not proficient in Java I suppose). The bigger challenge is the Python standard library which is very poorly documented. I spent almost a full day yesterday implementing a web server that supports "multipart/form-data" using the built-in BaseHTTPServer and cgi classes based on the documentation. I think the main issue was that I was using version 3.0 and it appears that this release is perhaps a bit too new to be used for production. When I ported my code back to version 2.5.1 it worked fine.

Python is undergoing some major changes at the moment and version 3.0 was released just a few weeks ago. There are some pretty fundamental changes between version 2.6.x and 3.0 such as "print" changing from being a statement to being a function, that make it impractical, to say the least, to write code that can work with both versions.

I have decided to stick with version 2.5.1 for now and port my code at a later date once 3.0 is stable enough (and once binary distributions are available for the platforms we need to support).