McWong: May 2008 Archives

I'll start this off by saying this is pure opinion.  I don't have any statistics.  Instead I have some gut intuition based on numerous "enterprise Java" projects within my company, and through observing the development community.

I'm currently involved in architecting a next generation systems management framework.  It has fairly hefty requirements... monitor and manage millions of objects distributed across the globe in real time.  Take out the "millions" bit, and this isn't so bad.  There are a bunch of standards out there (JMX, SNMP), there are some off the shelf tools, and you can knock something together pretty quickly that covers a reasonable subset of equipment for small installs.  But we need to do better.   We need to manage more than just "most" of the equipment, and we need to do it in some of the world's biggest data centers.  And as I talk about this with my peers from other groups,  I'm getting more convinced that J2EE has poisoned a good chunk of the current generation of architects.

I know this isn't how J2EE  has to work, but in most projects, you start them like this...
1) Build your object model, use magic to map it to the DB
2) Build your business logic
3) Build your front end
4) Ship it!

And there you are.  You have a nice central database so you don't have to worry about distributed data so much.  It's all nice and safe on the disk.  You have some adapters to get stuff in and out, and a cozy UI that serves it all up to the user.  And it scales... for as much load as you can throw at your desktop.

Then you take it to some place big.  And it just flat out doesn't work.  It's not a matter of getting a bigger database, because you just can't scale it up past a certain point. You can cluster, but now you need a professional services group to install your product, and the performance gains to be had aren't crystal clear.

It becomes a matter of deciding what goes in there.  And when, and how.  But looking forward to these issues is met with fierce resistance in design meetings... Building distributed systems is much harder than building something around a central store.  Objections are typically based on reading marketing propaganda from database vendors.  Responses of the form "well, we'll partition the data when we hit that load.  Or use a cluster... yeah, a cluster will fix everything" are extremely painful to work through.  After all, some "expert" from VendorX says it will work. Who are you, my peer, to assume you know more than me?  

But guess what?  Each of these objectors has a product in the field, based a central database, handling far less load than our targets, and none of them scale well.

Scaling out is beating scaling up.  Processors are going multi-core, not taking huge leaps forward in the GHz war.  Scala and Erlang are gaining in popularity, and with them a different model of parallelism (not new, just different) than that offered by J2EE.  The actor model embraced by both of those languages is primarily targeted at small processes within a service.  But as you look at larger chunks of the architecture, I think the sanest way forward is to embrace a similar model.  

ESB has been a buzzword for years now.  I don't buy all the marketing hype around it, but at its core there is a model that the current generation of architects needs to get a handle on.  It's very similar in concept to the Erlang/Scala actor model.  Yes, it's harder to design around asynchronous messages and a large number of distributed components.  But that's how you handle the big problems.  And that's why you hire good developers to work on them, not just some random CS grad who happens to be able to regurgitate the latest Spring book.  

I'm not saying there isn't a place for the traditional J2EE buildout (rails has a similar model, and works wonderfully for small-medium sized projects).  And in fact, even with these asynchronous systems there are almost certainly services that need a DB backing them.  But there are other tools that should be in your toolbelt.

My suggestion to Java architects today would be to pick up another language that fosters a totally different architecture.  I'm currently biased towards Ruby, Erlang or Scala.  There are no guarantees that any of these scale better than Java (and it's fairly easily arguable that Ruby doesn't).  But any of these will make you see the world in a different way, and allow you to more effectively consider and evolve your current architecture.
So I went to the last half of Scala Lift Off on Saturday (only half, because the first half was taken up by my final MBA class.  Ever.).  I went primarily out of curiosity, not knowing much about Scala or Lift.  The main draw was the built in comet support for Lift, which seems to not be a focus in other frameworks... at least not for Rails.  We currently use Juggernaut for comet support, but depending on flash is something of a liability (see: iPhone), and Juggernaut itself isn't as smoothly integrated with Rails as i'd like.

I came away extremely impressed.  Scala is relatively unheralded in the world of alternative JVM languages (see Groovy, Jython and JRuby publicity), but shows a lot of promise.  It's a functional language with an expressive syntax that allows you to easily create code that looks DSL-ish.  These are the primary features that drew me to Ruby (ok, Ruby isn't a functional language, but you can sorta fake it).  But Scala has a better integration story with existing Java libraries, is strongly typed, and has a stronger functional bent.

I'm a big believer in the right tool for the job, and as such don't fall into a pure-dynamic or pure-static language camp.  I also don't fall into a single language camp. I really enjoy Ruby for quick prototyping, and love Rails for quick prototyping of webapps, and maintaining a nimble production face on web applications.  But Rails falls down when I need to run background processing.  The times I think hardest about moving back to a Java webapp environment are when I need to go write something that doesn't just receive a web request and terminate.  This is where concurrency issues get painful to deal with, Ruby daemons/DRb are painful, and starting up a whole Rails env for simple processing is rough.

So I'm hoping Scala/Lift fills that void.  I'm mentally sketching out a replacement of our background processing jobs (Twitter integration, email processing, etc.) with Scala, and in particular the Actors library.  These are relatively simple processing tasks, and should give me a decent feel for the language.  It should also improve the stability and scalability of our background processing.  It may also yield some reasonable libraries to contribute back (Scala Twitter library, Scala ActiveRecord bridge). 

Once I have that nailed down, an evaluation of how Lift can/should fit into the framework is in order... or maybe I'll have to start my Rettiwt side project based on Lift.


About this Archive

This page is a archive of recent entries written by McWong in May 2008.

McWong: April 2008 is the previous archive.

Find recent content on the main index or look in the archives to find all content.