No swap space?

3,293 views
Skip to first unread message

Ray Pitm

unread,
Jan 7, 2014, 10:13:57 PM1/7/14
to gce-dis...@googlegroups.com
Hi,

I had an instance run out of memory due tonight, and had to reboot in order to get back into it.  I started looking around and realized that there is no swap partition on any of my instances.

Is this by design?

Top looks like this:

top - 03:08:13 up 28 days,  2:29,  1 user,  load average: 0.43, 0.13, 0.08
Tasks:  72 total,   1 running,  71 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.1 us,  0.0 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:   7681884 total,   819208 used,  6862676 free,   143124 buffers
KiB Swap:        0 total,        0 used,        0 free,   333416 cached

There isn't an entry for a swap partition in /etc/fstab..  /proc/swaps is empty..

I can't imagine that we would have to manually set up a swap on an instance after creation.  Is there some special thing about these instances that they don't require any swap?  I looked around and could find no info regarding swap on GCE.

thanks!

-Ray


CONFIDENTIALITY
The information transmitted herein is intended only for the addressee and may contain confidential, proprietary and/or privileged material. Any unauthorized review, distribution or other use of or the taking of any action in reliance upon this information is prohibited. If you receive this email in error, please contact the sender and delete or destroy this message and all copies.

Greg

unread,
Jan 8, 2014, 12:15:23 PM1/8/14
to Ray Pitm, gce-dis...@googlegroups.com
I suspect that you need to set up swap yourself.

-Greg
> --
> © 2013 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
>
> Email preferences: You received this email because you signed up for the
> Google Compute Engine Discussion Google Group
> (gce-dis...@googlegroups.com) to participate in discussions with other
> members of the Google Compute Engine community and the Google Compute Engine
> Team.
> ---
> You received this message because you are subscribed to the Google Groups
> "gce-discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gce-discussio...@googlegroups.com.
> To post to this group, send email to gce-dis...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gce-discussion/5f5b4964-eaba-4d1e-80c2-3975a4205f3e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Anthony Voellm

unread,
Jan 8, 2014, 12:52:28 PM1/8/14
to Greg, Ray Pitm, gce-dis...@googlegroups.com
Generally servers don't have swap enabled.  Swap tends to lead to unpredictable performance.  if you want swap space you want to either increase the size of your root drive or add a secondary drive (PD).  Keep in mind that PD IOPS scale with the size of the disk.  So in other words bigger disks are faster and for a swap device you'll want it to be fast.  My minimum recommendation would be 200GB for swap for infrequent swapping.

The other option is to use one of the himem instance types.






--
Anthony F. Voellm (aka Tony)
Google Voice:  (650) 516-7382

Ray Pitm

unread,
Jan 9, 2014, 12:10:11 AM1/9/14
to gce-dis...@googlegroups.com, Greg, Ray Pitm
I had a server run completely out of memory due to a problem with an app.. If I had swap, the VM might have stayed up (or maybe the app would have just chewed that up as well).  Anyway, I think having swap as a safety net is a good idea, even if it never gets used.

I added a couple gig swap file to my root drive - will that be a problem since it's so small, or is the root drive faster than a small secondary PD?

thanks,

-Ray

Leif Pedersen

unread,
Jan 9, 2014, 12:40:13 AM1/9/14
to Ray Pitm, Greg, gce-dis...@googlegroups.com

I could see swap vs no swap being an argument with no clear answer, because of varying circumstances and priorities.

The general question is, Is random access within a 2GB partition on a 200GB disk as fast as random access across the whole 200GB disk? I imagine various ways of sharding a virtual disk across the physical storage that answer this question differently, so what should we plan for?

Peter Woodman

unread,
Jan 9, 2014, 12:42:52 AM1/9/14
to Ray Pitm, gce-dis...@googlegroups.com, Greg, Ray Pitm
I'm just gonna jump out and say that swap is never a thing you want on a machine these days. memory is chosen over disk for performance reasons and it's not good to conflate the two. If something is misbehaving, trust that the oom killer will kill something noncritical (it's generally pretty good at that- give it hints using /proc/$pid/oom_score_adj if need be) and depend on process supervision to bring back the part of your architecture that was killed. if you need more memory, start a larger instance. 

tl;dr it's definitely not something you want without asking for it. 

Leif Pedersen

unread,
Jan 9, 2014, 12:52:03 AM1/9/14
to Peter Woodman, Greg, gce-dis...@googlegroups.com, Ray Pitm

Well, if you don't know the priorities of his system, it's silly to say swap shouldn't be used. Some very smart people invented swap for some very good reasons, and we don't know whether his priorities align with those reasons.

The general question is important for lots of workloads. I wanna turn up MySQL with a smallish data set, but if the performance is gonna suck because a 2GB data set can't be performant, I need to look at alternative solutions.

Mine is really the same question as his, with a different application. Thoughts?

Peter Woodman

unread,
Jan 9, 2014, 1:04:12 AM1/9/14
to Leif Pedersen, Greg, gce-dis...@googlegroups.com, Ray Pitm
Mysql will always perform better with a buffer pool sized correctly for the machine it is running on and no swap. 
Reply all
Reply to author
Forward
0 new messages