I’m going to be moving from a VPS to a dedicated box in the next few
weeks and am thinking about configuring it with Xen, and wondered if
anyone had any thoughts about this and specifically how the various
instances should be set up.
Bit of background – I’m not a computer professional by background.
Got into it through sorting the IT for a small company I ran and
ending up building our website (PHP hackery) and setting up a couple
of Linux boxes. Rails (and Ruby) have been a revelation, and added
some sorely needed structure to my coding. All this means I’m learning
as I go along, and sometimes it’s a steep learning curve (for example,
I’ve had zero experience of Xen).
Currently I’m on a VPS with 160MB of Ram, running Debian 3.1, nginx
and mongrel-cluster, all of which is fine (well, Debian’s a bit of a
pain sometimes, what with having to building half the things you need
from source because the sources are too old, but it’s a pain I’m sort
of familiar with).
So, questions:
Xen – a good idea at this stage?
Debian – the right distro for Xen, or would Ubuntu server be
better?
How should I divide the instances – I’m thinking, for the moment,
of nginx + mongrel instances on one instance, MySQL on another, and
possibly asset storage (photos, cached files) on a third.
I’m using the db for sessions at the moment and only using fragment
caching, on the FS. Should I rethink these and look at memcached
(something else I know nothing about)
What about memory allocation between the instances (and would 2GB
be a reasonable amount of total memory to start with)
Any gotchas?
Hope I’m not taking the piss with all these questions. Any suggestions
gratefully received,
Chris
Debian – the right distro for Xen, or would Ubuntu server be
Debian decided to go with OpenVZ [ http://openvz.org/ ], so the
packages are in etch by default. Ubuntu decided to go with Xen, so you
can find all needed packages in edgy.
If it is just for security separation, take a look on OpenVZ - not a
bad option at all
Memcached? Will you REALLY have a LOT of instances? Because memcached
make a sence just in this case - shared storage. My opinion: go with
AR session store and if not fast enough - sql sessions store [ http:// railsexpress.de/blog/articles/2005/12/19/roll-your-own-sql-session-
store ]
Gotchas? nginx is good with serving static files (assets), why to not
put them together (nginx+assets) and have mongrels in another container
I’m going to be moving from a VPS to a dedicated box in the next few
weeks and am thinking about configuring it with Xen, and wondered if
anyone had any thoughts about this and specifically how the various
instances should be set up.
Congrats. I think this is a really forward looking solution.
If you deploy on a single box in this fashion, when the traffic comes
you’ll
have an entirely clear path to expanding:
Order new box
Install Xen
Determine which process is causing pain
Move already entirely configured environment onto new box
Revel in the new speed
Realize you could have done 4 while the instance was running, if
you had SAN storage!
All this means I’m learning
as I go along, and sometimes it’s a steep learning curve (for example,
I’ve had zero experience of Xen).
The extra overhead of learning a few critical Xen commands to manage
the system is trivial compared to the advantages, IMHO.
So, questions:
Xen – a good idea at this stage?
Debian – the right distro for Xen, or would Ubuntu server be
better?
I’d recommend Gentoo, but that’s just me.
How should I divide the instances – I’m thinking, for the moment,
of nginx + mongrel instances on one instance, MySQL on another, and
possibly asset storage (photos, cached files) on a third.
I’d split them this way:
nginx with the shared storage mounted, proxying to:
at least two separate instances running mongrel_cluster, each
accessing
NFS storage for this instance and
MySQL on its own instance and
a MySQL replica because you’ll be happy to have it when you need
it, and it makes backing up the DB while the system is live very easy.
I’m using the db for sessions at the moment and only using fragment
caching, on the FS. Should I rethink these and look at memcached
(something else I know nothing about)
I wouldn’t worry about it until you need it. When you do, bring up new
Xen
instances for memcache.
What about memory allocation between the instances (and would 2GB
be a reasonable amount of total memory to start with)
nginx @ 128M-192M
mongrel_cluster instances @ 256M-384M (determined by actual usage)
I’m really not sure what an NFS server needs, probably 128M-256M
MySQL @ 512M-1024M (I’d basically give it whatever you don’t use
elsewhere)
Memcached? Will you REALLY have a LOT of instances? Because memcached
make a sence just in this case - shared storage. My opinion: go with
AR session store and if not fast enough - sql sessions store [ http:// railsexpress.de/blog/articles/2005/12/19/roll-your-own-sql-session-
store ]
SQL Session Store is easy to setup and faster than AR, there is no
reason to try first with AR for sessions.
Down that road lies the (personally experienced!) insanity of
pre-optimization of everything, because it’s all easy.
Only…it’s not. And even if it was (or is!) it takes time and
must be maintained.
I think sql-session-store is super-cool, and I cannot express my
thanks to Stephan Kaes adequately, but most people simply don’t need
it (immediately).
I completely agree with you, but (in my experience) the setup and
maintenance of AR Sessions Store and SQL Session Store are just the
same. So why don’t use the fastest one? And yes Stephan must receive
some kind of recognition from the community for his bright work
Memcached? Will you REALLY have a LOT of instances? Because memcached
make a sence just in this case - shared storage. My opinion: go with
AR session store and if not fast enough - sql sessions store [ http:// railsexpress.de/blog/articles/2005/12/19/roll-your-own-sql-session-
store ]
SQL Session Store is easy to setup and faster than AR, there is no
reason to try first with AR for sessions.
Down that road lies the (personally experienced!) insanity of
pre-optimization of everything, because it’s all easy.
Only…it’s not. And even if it was (or is!) it takes time and
must be maintained.
I think sql-session-store is super-cool, and I cannot express my
thanks to Stephan Kaes adequately, but most people simply don’t need
it (immediately).
That is my opinion of Xen It’s great as a way to segment
applications for security purposes in say a shared hosting
environment, it’s also sweet in a staging/development environment for
quickly building new machines. But in a dedicated, static deployment
environment, I don’t see the value (and I don’t see the scalability
either) besides possibly being able to easily move to another
environment (but how often does that really happen in a deployed
application?)
In your example of splitting mysql into a virtual machine and
Rails/mongrel in a virtual machine as opposed to running them both on
a dedicated operating system, you are now running a two full
operating systems instead of two processes (or groups of processes).
I am sure there are many on this list that disagree
I guess the idea would be to make things scale better – so it’s
easier to move to a multi-server setup if and when. However, I could
be just getting seduced by the buzz around Xen – hence the post.