News for hackers. Stuff that matters.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @06:38PM (#45662628)
How do you get swap on a VPS?
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by justsomehnguy on Tuesday October 21, 2025 @07:32PM (#45663111)
Search "linux enable swap in a file"

    To enable a swap file in Linux, first create the swap file using a command like sudo dd if=/dev/zero of=/swapfile bs=1G count=1 for a 1GB file. Then, set it up with sudo mkswap /swapfile and activate it using sudo swapon /swapfile. To make it permanent, add /swapfile swap swap defaults 0 0 to your /etc/fstab file.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by collinmanderson on Tuesday October 21, 2025 @08:00PM (#45663334)
Yes. I think might also need to chmod 600 /swapfile. I do this on all my VPS, especially helps for small VPS with only 1GB ram:

   fallocate -l 1G /swapfile
   chmod 600 /swapfile
   mkswap /swapfile
   swapon /swapfile
Works really well with no problems that I've seen. Really helps give a bit more of a buffer before applications get killed. Like others have said, with SSD the performance hit isn't too bad.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @10:02PM (#45664144)
IME SWAP has been explicitly disabled by the VPS providers.

Partly it's a money thing (they want to sell you RAM), partly it's so that the shared disk isn't getting thrashed by multiple VPS

Re:Replacing a $3000/mo Heroku bill with a $55/mo server by efreak on Wednesday October 22, 2025 @04:02AM (#45666094)
Get better VPS then. Openvz and other kernel paravirtualization have limits, go for Xen or KVM instead (Xen has paravirtualization as well, but I'm not sure how much it's actually used). Full virtualization (implemented by Xen and KVM) do not allow you to prevent swap from being used.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by collinmanderson on Wednesday October 22, 2025 @01:08PM (#45672114)
I forgot to mention what the parent comment said, yes, need to put something like this in /etc/fstab:

/swapfile swap swap sw 0 0

or via ansible:

    mount:
      src: "/swapfile"
      name: "swap"
      fstype: "swap"
      opts: "sw"
      passno: "0"
      dump: "0"
      state: present
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @07:33PM (#45663117)
Strongly suggest you try doing that on a VPS, then report back
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by ahepp on Tuesday October 21, 2025 @07:44PM (#45663205)
What do you think is going to happen? I tested it out on an ec2 instance just now and it seems to have worked as one would expect.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @08:35PM (#45663613)
EC2 != VPS
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by cmpxchg8b on Wednesday October 22, 2025 @01:28AM (#45665189)
They both offer virtualized guests under a hypervisor host. EC2 does have more offload specialization hardware but for the most part they are functionally equivalent, unless I'm missing something...
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by ahepp on Wednesday October 22, 2025 @10:22PM (#45677481)
What VPS do you think this would cause problems on? Why?
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by Zekio on Wednesday October 22, 2025 @04:57AM (#45666456)
well once you "need" that swap, it will be writing pages across the network due to the storage being external to the physical server, so the latency is terrible
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by kassner on Wednesday October 22, 2025 @05:38AM (#45666737)
Put swap on the “instance store” disk, not EBS.
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by ahepp on Wednesday October 22, 2025 @10:19PM (#45677456)
Latency of swap is always terrible in comparison to RAM. RAM vs disk is already something ~1000x right? I've never characterized EBS vs trad ssd, but I would be surprised if it's more than 10x.

I don't think using swap as "emergency RAM" makes a lot of sense in 2025. The arguments in favor of swap which I find convincing are about allowing the system to evict low use pages which otherwise would not be evictable.

Re:Replacing a $3000/mo Heroku bill with a $55/mo server by justsomehnguy on Tuesday October 21, 2025 @07:51PM (#45663268)
https://news.ycombinator.com/item?id=45007821

And that was like... two years ago? 1GB of RAM and actually ~700MB usable before I found the proper magik incantations to really disable kdump.

Also have used 1GB machines for literally years.

Strongly suggest you shouldn't strongly suggest.

Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @08:37PM (#45663625)
Uh.. your link... doesn't show how a VPS can have SWAP enabled

You do understand what's being discussed... right?

Re:Replacing a $3000/mo Heroku bill with a $55/mo server by justsomehnguy on Tuesday October 21, 2025 @08:53PM (#45663739)
Literally up the chain: https://news.ycombinator.com/item?id=45663111

Or you have a very peculiar understanding what 'VPS' means.

Re:Replacing a $3000/mo Heroku bill with a $55/mo server by awesome_dude on Tuesday October 21, 2025 @11:24PM (#45664617)
Re:Replacing a $3000/mo Heroku bill with a $55/mo server by justsomehnguy on Wednesday October 22, 2025 @03:52PM (#45674279)
Hello, it's the year 2025 here. If you use OpenVZ-like ancient shit - it's on you.

So no, VPS is a proper virtualization for a 15 years. And with a proper virtualization you have the full control.