DO Ideas 2

Add swap space to images

I've noticed my linux images didn't come with any swap space and had to allocate it myself. It would be nice to have space space allocated already in the linux images.

  • Adam Bronte
  • Sep 11 2018
  • Attach files
  • Ben Hickson commented
    September 11, 2018 19:35

    **Not all instances, just your LAMP preset. that one seems built for Wordpress and similar RAM-heavy apps, so let's give it some swap.

  • Saimon Lovell commented
    September 11, 2018 19:35

    I need swap bad. Some software refuses to write to ram for security reasons.

  • roger pack commented
    September 11, 2018 19:35

    Here's an instance of a customer who ran into problems because of no default configured swap space: http://digitalocean.uservoice.com/forums/136585-digital-ocean/suggestions/3778309-better-cpus-for-512mb-plan-or-provide-swaps

  • Svjatoslav Agejenko commented
    September 11, 2018 19:35

    Swap is very justified for consumer. I might have virtual machine with occasional large spikes in RAM usage while VM responsivness is not an issue or priority. By using swap, there is no need to buy enough RAM to cover those spikes. Also it increases stability, because for low traffic server its better to hit swap that crash with OOM. Also often lots of allocated RAM is not in active use, so moving it to swap allows to run at less physical RAM without significant performance impact.

    From hosting company perspective heavy swap usage means more disk I/O bandwidth. And since this bandwidth is shared across virtual machines, it is probably significantly expensive resource.

  • Chris Bond commented
    September 11, 2018 19:35

    dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576
    mkswap /swapfile
    chown root:root /swapfile
    chmod 0600 /swapfile
    swapon /swapfile

    add this to /etc/fstab:
    /swapfile swap swap defaults 0 0

    Should be default on low-end machines otherwise lamp doesnt work well

  • Moisey Uretsky commented
    September 11, 2018 19:35

    We've written articles in our community on how to add swap space which can be found at:

    https://www.digitalocean.com/community

    There are positives and negatives to both approaches we went with no swap to simplify setup and give customers the choice.

    Thanks

  • Mateusz Adamowski commented
    September 11, 2018 19:35

    That's great you did it yourself. Not everyone needs swap space in their system. DOWNVOTE.