7

I have a production server with 16GB of RAM that came with a 32bit CentOS installation.

The website hosted on this server is getting increasing amounts of traffic every day, which has led to some some MySQL performance issues. I ran mysqltuner.pl and got the following messages:

[!!] Switch to 64-bit OS - MySQL cannot currently use all of your RAM
  *** MySQL's maximum memory usage is dangerously high ***
  *** Add RAM before increasing MySQL buffer variables ***

Can I survive with the 32 bit OS, or do I need have to install the 64 bit version?

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • 12
    I'm pretty sure the giant warning coming out of MySQL has answered this question for you already. There's pretty much no good reason to be using a 32-bit server OS on hardware released in the last five years. – jgoldschrafe Oct 02 '12 at 11:00
  • 2
    There's some rabid downvoting on this site lately. – gravyface Oct 02 '12 at 11:14
  • 3
    The warning is incorrect. MySQL can use all your RAM, it just can't map it, which makes its use of large amounts of RAM much less efficient than it would be with a 64-bit OS. – David Schwartz Oct 02 '12 at 11:30
  • 6
    @gravyface Some rabid upvoting too. 4 upvotes on a question asking whether it's a good idea to use a 64 bit OS, given: >4GB RAM and app warning saying "switch to 64 bit OS" seems pretty excessive to me. I guess I'll choose to believe that my "innate superiority" is what makes it seem like a trivial question to me. – HopelessN00b Oct 02 '12 at 11:57
  • 8
    Why the server didn't come with 64 bit in the first place is a major concern to me... – tombull89 Oct 02 '12 at 12:00
  • You can always enable PAE to get up to 64GB ram support on a 32bit machine, however MysQL will only be able to use 4G (which might be 1-2G more then it has now) see http://serverfault.com/questions/127788/what-is-the-maximum-memory-a-process-mysql-can-consume-on-a-32-bit-os for some more information. – Jens Timmerman Oct 08 '12 at 09:06

3 Answers3

24

You can survive just fine with the 32 bit CentOS install. But, like the warning says, using a 32 bit OS means that MySQL can't actually use all (or even most of) the RAM installed in the system.

Seems like a waste to me. If the hardware supports 64-bit, I'd certainly replace the 32 bit OS with a 64 bit one, yeah. You'd probably want to do some testing first, and/or use a second server to find out what's going to break when you switch OSes, because something always does.

Strictly speaking, you don't need to install a 64 bit OS, but you definitely should. And probably sooner, rather than later, before the RAM limitations of a 32 bit OS start causing you problems.

HopelessN00b
  • 53,385
  • 32
  • 133
  • 208
  • 1
    We should mention that this limit counts for every single process, however if mysql is the main task of this machine as that is a single process (with multiple threads) going 64 bit will be worth it. – ZaphodB Oct 02 '12 at 13:07
13

Maximum virtual address space of a 32 bit binary is 2^32 (4GB) - once you hit this limit, you're going nowhere.

Should you switch to 64-bit? Absolutely.

Not only will you no longer hit the memory barrier, the generic 64-bit instruction set has generally better performance than generic 32-bit (due to the sheer age of x86) and thus, switching to x64 will give gains in terms of both memory and computational speed.

Obviously if you custom-compiled x86 binaries yourself with the arch target of your exact CPU, you could well find that performance compared to x64 is not all that different, however, since you're using pre-packaged CentOS binaries, obviously that's not the case.

Olipro
  • 2,967
  • 18
  • 18
  • 1
    [To be a little nitpicky, 32-bit OSes can/may be able to access RAM in excess of 4GB with PAE.](http://en.wikipedia.org/wiki/Physical_Address_Extension) Otherwise a spot-on answer, and +1 anyhow. – HopelessN00b Oct 02 '12 at 12:08
  • 5
    @HopelessN00b Yes, with PAE, the kernel can address all 16GB of RAM, but any particular process is still limited to a bit less than 4GB. – Michael Hampton Oct 02 '12 at 12:16
  • 4
    IIRC you can implement PAE at the application level as well; and that it used to be fairly common among DBs and other memory hungry server apps back before x86-64 hardware was common. However with it now ubiquitous PAE code branches are being deprecated/abandoned due to lack of use sufficient to justify continued development work. – Dan Is Fiddling By Firelight Oct 02 '12 at 12:39
  • 1
    *"...generic 64-bit instruction set has generally better performance than generic 32-bit (due to the sheer age of x86)"* -- This is a dubious statement. While it's true that 64-bit **code** is generally faster than 32-bit **code** (for various reasons including register size, memory bandwidth, and better optimization), the performance difference has nothing to do with how long x86 has been around. In fact, x86_64 is an **extension** of x86 and it therefore could be argued that the instruction set's history stretches all the way back to 1986. :-) – Justin ᚅᚔᚈᚄᚒᚔ Oct 02 '12 at 14:53
  • Justin: no. All x86_64 processors are guaranteed to have certain x86 extensions SSE, SSE2 and several others, thus enabling the compiler to utilise a significantly larger instruction set when targeting the generic x86_64 architecture vs. generic i(3|4|5|6)86 – Olipro Oct 03 '12 at 15:33
  • @Olipro: Yes, I'm aware of the SSE2 guarantee on x86_64, but your answer *as worded* suggests that x86_64 is faster than x86 *solely because x86 is an "old" technology*. My comment was intended to clarify that point. Also, switching from 32 to 64-bit OS on the same x86_64 system will have little noticeable impact since the CPU extensions available in 32-bit mode are there regardless of the OS. But, changing **CPU** from an IA32 to an x86_64 *may* provide a benefit, assuming that the IA32 CPU doesn't provide the extensions that the x86_64 does, and that x86 code is recompiled for the new extns. – Justin ᚅᚔᚈᚄᚒᚔ Oct 03 '12 at 18:17
  • It is irrelevant what the x86 CPU does or does not support because a generically targeted compile will not have any additional instructions. I prefer not to be arguing semantics over how I said something, I feel the way I made the same point is clearer and more concise. – Olipro Oct 03 '12 at 19:47
  • @Olipro: My apologies, my intent was not to offend you or denigrate your answer. I just tend to prefer correctness over conciseness so felt the need to clarify your comment about the instruction sets. At the end of the day, switching to a 64-bit kernel and using the 64-bit binaries of important packages will certainly benefit the OP in multiple ways and should be done except in specific scenarios (none of which seem to be the case here). – Justin ᚅᚔᚈᚄᚒᚔ Oct 03 '12 at 20:50
3

Although answer has been accepted, there's a lot of stuff missing from the discussion here.

First: Alexandru does not mention what database engines are running on this machine, nor whether it's a dedicated DBMS server or if it's also running other stuff, nor what size the data is, nor any stats on physical I/O / VFS usage.

For a dedicated MyISAM based server, then you're not going to get much benefit from making more memory addressable. VFS does as good a job of caching the I/O as MySQL can. OTOH if it were innodb - then by golly, yes: the innodb buffer pool on a dedicated box should be around 80% of the phsyical memory on a dedicated machine.

Regardless of which DBMS is used, switching to 64bit has significant a performance benefit when doing comparison operations on the DBMS - how much depends on whether you're doing a lot of hash or b-tree based lookups.

If the same box is being used for webserving, then the big difference will be if you're using a lot of SSL on the box - SSL is all about calculating large numbers - so even without the AES acceleration in recent intel chips there's an improvment there too.

symcbean
  • 19,931
  • 1
  • 29
  • 49
  • I am serving a Real Estate website that you can see here http://bit.ly/fwTEsT , so the server is doing all sorts of things. Database, serving website, image resizing, cron jobs, sending mails and so on. I have finally decided to take advantage of this situation and change the hosting to a dedicated server in the same country the business is. That server will have the 64bit OS installed already. – Alexandru Trandafir Catalin Oct 05 '12 at 12:10