Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Can you use spare RAM to make your VPS faster for dev/low traffic?
New on LowEndTalk? Please Register and read our Community Rules.

Can you use spare RAM to make your VPS faster for dev/low traffic?

I have a VPS I use for PHP development, and it has 1GB of RAM, but I only use 1-200mb for nginx/MySQL

Are there any config changes I can make that will use more RAM but result in improved performance (just overall speed/loading/responsiveness)?

It's OpenVZ

Favourite host in general: Ramnode (affiliate link)
Favourite host for hourly billing/custom ISOs: Vultr ($50 free credit for new accounts, affiliate link)

Comments

  • You could load your website files into a RAM disk so they're read directly from memory.

    Thanked by 2Gunter hostnoob

    My personal blog and website | Freelance web developer & programmer. HTML/CSS/PHP/JS (Clientside & Serverside)/C# and more

    Installing Observium on Debian

  • The Linux kernel is a technological marvel. It will intelligently cache as many files as possible into RAM automatically. Because of this, I'm thinking this is not an issue with reading from the disk. Maybe the DB or complex PHP syntax. You could try precompiling the PHP and checking if SQL needs some optimisations.

    Thanked by 1hostnoob
  • matthewvzmatthewvz Member, Provider

    A RAM disk and a rsync script (for no loss of data in case of power loss, etc) would be your best bet.

    Thanked by 1hostnoob
  • Can you be more precise about what is slow with your current configuration?

    Thanked by 1hostnoob
  • @Microlinux said:
    Can you be more precise about what is slow with your current configuration?

    Sorry guys, it's not slow but I just thought with all this unused RAM maybe I could do something with it.

    Favourite host in general: Ramnode (affiliate link)
    Favourite host for hourly billing/custom ISOs: Vultr ($50 free credit for new accounts, affiliate link)

  • jcalebjcaleb Moderator

    Try also to config your MySQL to use more RAM here and there to improve performance

    Thanked by 1hostnoob
  • shovenoseshovenose Member, Provider

    You can downgrade to a cheaper, smaller VPS.

  • @shovenose said:
    You can downgrade to a cheaper, smaller VPS.

    I could but my EU VPS is only £2/mo and I have one that only cost $10/yr for 512+512 burst

    Favourite host in general: Ramnode (affiliate link)
    Favourite host for hourly billing/custom ISOs: Vultr ($50 free credit for new accounts, affiliate link)

  • jcalebjcaleb Moderator

    try also php accelerator. it consume more ram but php code will load faster

    Thanked by 1hostnoob
  • publiopublio Member

    Cache, cache, cache. With extra RAM, caching is the order of the day. Have your php code send cache headers and let nginx have a generous cache expiration time.

    Lowering your vm.swappiness may help your system by making it swap only in emergencies.

    Thanked by 1hostnoob
  • publio said: Lowering your vm.swappiness may help your system by making it swap only in emergencies.

    Linux is very optimal by default on the amount of swapping. I would not attempt to personally optimise something that the greatest programmers have done for us. Let Linux optimise - because it can do so a lot better than us.

    Like when people optimise Java code. They optimize to the point where the Java Virtual machine is unable to optimise. This results in much slower code - because of the excess optimisation. Java developers quickly learn to stop optimising and micro-managing.

  • rm_rm_ Member
    edited May 2014

    hostnoob said: I just thought with all this unused RAM maybe I could do something with it.

    For those people with 6GB VPSes, thinking about this is practically all they do. :)

    I would enable XCache, it caches processed PHP bytecode in RAM, so it doesn't have to be parsed at every page load from the PHP source-code. But even then the XCache would only consume 50 MB at most, it your site is not overly large (doesn't have a crazy amount of .php files).

    There's a number of other similar tools, notably APC seems also good.

    Thanked by 1hostnoob
  • wychwych Member
    edited May 2014

    RAM Disk + Re-configure MySQL, few cache systems may help.

    Thanked by 1hostnoob

    Taking a hiatus.

  • BogdacutuuBogdacutuu Member
    edited May 2014

    @Silvenga said:
    Linux is very optimal by default on the amount of swapping. I would not attempt to personally optimise something that the greatest programmers have done for us. Let Linux optimise - because it can do so a lot better than us.

    Then can you please explain why the greatest programmers have decided to set a swappiness of 60 by default on Ubuntu when I have 20 GB of RAM? Do these great programmers not understand that RAM is faster than disk?

  • CoreyCorey Member, Provider
    edited May 2014

    @Bogdacutuu said:
    Then can you please explain why the greatest programmers have decided to set a swappiness of 60 by default on Ubuntu when I have 20 GB of RAM? Do these great programmers not understand that RAM is faster than disk?

    Pretty sure that's a default swappiness for any system. That's why it's configurable - BUT... if it's getting swapped... you probably don't use it very often anyway... and if you have that much ram and you aren't using near any of it - why do you have that much ram in the first place?

    BitAccel - OpenVZ VPS / IRC,VPN,Anything Legal & Unrivaled Support!
  • Bogdacutuu said: Then can you please explain why the greatest programmers have decided to set a swappiness of 60 by default on Ubuntu when I have 20 GB of RAM? Do these great programmers not understand that RAM is faster than disk?

    Your logic does not make sense. So swappiness is set to 60. Do you know what that means? You need to look into the algorithm yourself - 60 is a weight and not a percent.

    http://unix.stackexchange.com/questions/32333/what-does-the-vm-swappiness-parameter-really-contol

  • @rm_ said:
    There's a number of other similar tools, notably APC seems also good.

    Does xcache work well with Nginx? I thought it was made to work with lighttpd

    Favourite host in general: Ramnode (affiliate link)
    Favourite host for hourly billing/custom ISOs: Vultr ($50 free credit for new accounts, affiliate link)

  • namhuynamhuy Member

    why not try memcached ?

  • rm_rm_ Member
    edited May 2014

    hostnoob said: Does xcache work well with Nginx? I thought it was made to work with lighttpd

    No idea, I just use Lighttpd everywhere. Xcache seems to load into PHP, not into the web server, so it doesn't seem to be server-specific. And in fact, the Wikipedia list marks both XCache and APC as working with both Apache and Nginx. Use whatever works best for you.

  • sleddogsleddog Member
    edited May 2014

    Bogdacutuu said: Then can you please explain why the greatest programmers have decided to set a swappiness of 60 by default on Ubuntu when I have 20 GB of RAM?

    The default swappiness of 60 is geared towards the desktop environment. Server environment is very different.

    I always set swappiness = 0 on VMs. This doesn't disable swapping, it just reduces it to a "gotta do it, no choice" situation.

  • From what I understand by default the Linux kernel will copy pages to swap even if it's unnecessary at the moment, in case it needs to free up a large chunk of memory later on. That way when you do need the ram, it's already been moved to swap and you don't have to wait for it to be written to disk so the ram can be freed.

    Be seeing you.

Sign In or Register to comment.