Always Get Better

Archive for March, 2011

Drizzle – MySQL for the Cloud

Thursday, March 24th, 2011

Drizzle – a lightweight fork of MySQL – has reached general availability. Drizzle’s design goals are to create a highly performant and module database engine tailored for cloud computing.

Some of the interesting features this database has to offer are:

  • No Views, Triggers, or Stored Procedures – I consider this a huge advantage. Stored Procedures were once a good thing when query optimizers were all but non-existant, but modern database systems perform this task extremely efficiently. Using stored procedures adds a second level of APIs to your application for what I would consider to be a rather dubious potential security benefit.
  • Sharding – The client protocol is designed to decide which database server to target based upon a hashing key. This is similar to how memcached handles its linear horizontal scaling – leaving this calculation to the client is a huge advantage to systems hosting a high number of concurrent visitors
  • Gearman Support – This is a terrific tool for spreading workload across machines. Use Gearman to handle logging in Drizzle, keeping the actual DB server available for database work

How Does Drizzle Compare to Percona?
Percona is a high-performance build of MySQL which promises to offer better performance than “stock” MySQL. It is built from a branch of publicly-available MySQL source code and enhanced by the folks at Percona. Percona maintains the same functionality as “real” MySQL, but attempts to achieve faster speeds.

How Does Drizzle Compare to MariaDB?
MariaDB is a different database engine started by the original creator of MySQL intended to replace MySQL using non-Oracle licensing. Anyone concerned with Oracle’s development practices or plans for the future of MySQL should consider switching to MariaDB. MariaDB implements all of the existing MySQL functionality plus more and provides a drop-in replacement for MySQL.

Defaulting Null Variables

Friday, March 4th, 2011

One of the things I miss most about C# is the expressive ways in which it handles variable defaults. The ‘double ?’ – ?? – operator is especially useful for checking whether a value is NULL and providing a default object:

Displaying Production-Only Markup in Rails

Thursday, March 3rd, 2011

If you are running something like Google Analytics on your website, you probably don’t want its associated JavaScript code to appear in your web browser while you’re developing (it would skew your statistics). In Rails, it is incredibly simple to block off a segment of markup for specific environments by using the Rails.env variable.

If you are using Passenger, your rails environment is set to ‘production’ by default, making it very easy to do something like this: