32 bit or 64 bit OS on a 512 mb VPS?

A 64-bit arrangement will not consume twice as much memory for the same task(s). Some code will be twice as big (both in RAM and on disk), and some data structures will be larger too due to larger pointers and for efficiency reasons (i.e. structures being padded to align with 64-bit boundaries rather than 32-bit ones), but most bulk data such as that held in RAM by a database will not have a noticeably larger footprint.

Using a 64-bit build may give you a bit of extra performance for CPU/memory intensive tasks as the code will be able to use the extra (and larger) registers available in the CPU instead of being limited to the fewer smaller ones available in 32-bit mode, and it may be more efficient from the hypervisor's point of view as it won't need as many context switches that involve jumping in and out of long (64-bit) mode.

My gut suggests going for the 64-bit option, unless you are relying on a 32-bit package that has no 64-bit version or code so you can compile up your own.

I would suggest trying both if you have time though: install something like VirtualBox on a home machine if you have one that is 64-bit capable and create two 512Mb VMs (one with a fully 32-bit install and one with a fully 64-bit one) with the mix of software you plan to use. This will give you a better indication of any difference you will notice than rules of thumb and guess work will.

As a side note: 4Gb is a lot of swap for a 512Mb machine, virtual or otherwise. If you have as much paged out to disk as you have in RAM then you are likely to see a significant performance drop due to swap thrashing (pages constantly being swapped between RAM and disk), if you get into a situation where you have 8 times as many memory pages on disk as you have in RAM I expect the VM will have long since effectively ground to a halt. Some of that space would be much better used as file storage if you have the option.


It won't consume twice the amount of RAM. It's a fair thing to say (once), where did you hear that?

As you aren't using any odd/old drivers, you aren't tied to 32bit. 64bit's biggest (but still tiny) advantage is bigger CPU registers, so go with that. Also, a 64bit processor is more likely to be newer and better, but I'm not sure that 32bit are lagging behind.