I have a Debian server VPS, and the provider installed 64-bit Debian 5. Should I ask for an 32-bit install, given that I have only 750 MB RAM and I have heard that variables take more RAM on 64-bit systems?
The short answer:
Variables do not take double the space in 64-bit vs 32-bit software. The potential memory gain from switching to a 32-bit OS will not be worth the effort.
The long answer:
Numbers can be larger yes, but that doesn't mean they will be. Also this applies to numbers, not strings, and strings are (generally) what consume the most amount of memory in an application.
Additionally, many applications explicitly specify the size of the number they want to work with, as in languages like C,
int can be any size, including smaller than 32-bit. And going even further, on my 64-bit Linux machine, in C
int is 32-bit. So you would have to explicitly request
long long to get a 64-bit number.
So basically, applications aren't going to use more memory just because they were compiled for 64-bit.
In response to Gilles' claim that 64-bit Firefox uses twice as much memory, I went and did a comparison between 32-bit and 64-bit Firefox on my system.
On the final run:
32-bit: 173,244kb rss / 918,348kb virt
64-bit: 184,588kb rss / 966,624kb virt
I could do more extensive testing yes, but I think this demonstrates well enough that the size difference between the two is marginal.
I choose 32-bit over 64-bit installs for systems with less than 4gig of ram.
64-bit DOES use more memory, due to the nature of it's pointers, this ranges between roughly 10 and 50 megabytes extra for a vanilla LAMP install.
On a system with limited ram, for example 256meg, this can be a sizeable chunk.
Technically, with PAE the same applies upto 64gig, however the addressable space for applications is still limited to 4gig in any case. Therefore with anything over 4gig, 64-bit is recommended to utilize the performance gains, not least those associated with PAE's overhead.
In a nutshell: <4gig = 32bit | >4gig = 64bit.
Except for a few number-crunching applications that run faster, the only benefit of a 64-bit system is that you can address more than 4GB of memory. Since some of the address space is reserved to the kernel, a process only gets about 2GB or 3GB of address space (or more or less, depending on the kernel configuration). For a database and web server use case, you aren't planning of swapping much, and you aren't going to do much number crunching. So, with only 750MB of RAM, you will not see any benefit of using a 64-bit system.
The code size is about the same between i386 (32-bit) and amd64 (64-bit) code. The data memory used by 64-bit program is somewhat larger; how much larger depends on the application. I would expect to see a noticeable, but not large difference for your use case.
Given that there is a little cost and no benefit to using 64 bits, I recommend that you use a 32-bit system, if it's not too much trouble to obtain.