By prashant on Jun 19, 2009
We released a new OpenSolaris Ruby on Rails image on Amazon EC2 last week. This version is different from the previous one on OpenSolaris because not only does this AMI include the usual goodies, updates etc., this is also a Typo appliance.
Want some marketing key words?
- Pre-configured, preinstalled, and very "appliancy"
- Extremely monitorable
Since I'm not really a marketing guy, I just can't put words out there without feeling a primordial urge to explain myself.
The stack (Ruby, extensions, gems, web servers) is compiled with the latest compilers, optimal compiler flags based on performance studies, and Nginx is configured to have its temporary file store on a tmpfs mount.
Nothing runs as root, even for an instruction. If you're wondering how Nginx can listen at port 80 without being started as root, the answer is easy - Solaris privileges: root is not a user, rather it's a role. So you can confer privileges (like listening on port 80) which are usually associated with root to other users (like the nginx user). So this obviates the necessity for applications(like Nginx or Apache) to run as root even for the brief set of instructions needed to bind to a port. The less instructions you run as root, the less your exposure.
Pre-configured, pre-installed, and very "appliancy".
The image contains a production ready configuration of Typo, which is the popular Rails blog engine(usage details are here). Its architecture: there are two Nginx workers. Nginx listens at port 80 and is a fast web server which reduces the possibility of application bottlenecks. In all likelihood, one cannot fully stress two Nginx workers in an EC2 instance (or even one, in my opinion) In addition, Nginx has a low memory footprint, so the benign effect of having two instances outweighs the overhead).
The Rails servers are powered by Thin. There are two instances that Nginx communicates with. Rails is a CPU-intensive/low concurrency application that benefits from multiple instances. The Thins are sized in anticipation of a single CPU so it may be wise to increase the number of Thin instances depending on the number of CPUs in the image.
MySQL is the database. The three tiers are pre-configured. Nginx communicates with Thin, and Thin communicates with the database. Typo has its schema populated into the MySQL database, Rails and its dependencies are already installed. The native gems, like MySQL and Thin have been compiled and configured correctly . . . and it "just works". To use it start the instance, and log on to http://instance to begin setting up your web log.
SMF services exist for the Nginx, Thin, and MySQL components, and the dependencies between these services are also expressed in the manifests.
The catalog entry has information on where the service manifests are stored, and where the components are installed for one who wants further control.
The AMI has DTrace support. DTrace provides for a low overhead profiling with fine-grained control over which code is being profiled. Please refer to Reference 2 below.
What's not in the AMI: one needs a backup mechanism for their weblog entries, this is something that the AMI does not provide at this time.
And that's it, please check out the AMI, and hope it is useful either in itself, as a starting point for an tiered architecture that can benefit from an SMF integration, and/or as a base Ruby on Rails AMI that can be used for building a private stack.