WordPress With Cheap VPS and 386MB Memory

Setting up WordPress on a VPS with just 386MB of memory sounded like a fun challenge, and it definitely delivered! With server this size I can closely look at performance of my application—if it’s barely running of course. If you’re looking to do the same, here’s a walkthrough of how I made it happen, all while working around the constraints of limited resources.

Luckily, PostgreSQL was already installed from a previous project, and I knew it would consume fewer resources than MySQL using default configuration. To make use of what I already have then I conduct a quick research how to make WordPress work with PostgreSQL, I came across the PostgreSQL for WordPress plugin. This open-source project bridges WordPress and PostgreSQL. The plugin had very simple documentation, which gave me confidence to proceed without much trial and error .

Here’s how I got everything set up:

  1. Create a PostgreSQL Database:
    Since PostgreSQL was already installed, the first step was to create a database and user specifically for WordPress. Here’s the SQL I ran:
    CREATE DATABASE wordpress; CREATE USER wp_user WITH PASSWORD 'strongpassword'; GRANT ALL PRIVILEGES ON DATABASE wordpress TO wp_user;
  2. Download WordPress:
    I downloaded the latest WordPress package and extracted it into my server’s web directory.
  3. Install the PostgreSQL Plugin:
    I cloned the PostgreSQL for WordPress plugin from its GitHub repository and placed it into the wp-content/plugins/ directory.
  4. Configure wp-config.php:
    I updated the wp-config.php file with the PostgreSQL credentials
    define( 'DB_NAME', 'wordpress' );
    define( 'DB_USER', 'wp_user' );
    define( 'DB_PASSWORD', 'strongpassword' );
    define( 'DB_HOST', 'localhost' );
    define( 'DB_CHARSET', 'utf8' );
    define( 'DB_COLLATE', '' );
    define( 'DB_TYPE', 'pgsql' ); // Set to PostgreSQL
  5. Run the WordPress Installer:
    With everything in place, I navigated to the WordPress installer in my browser and followed the usual steps. The PostgreSQL plugin handled the database connection perfectly, and before long, my blog was live!

Thats it, how this blog was created. But after reading a few articles, I found out that WordPress on PostgreSQL can be slightly slower compared to MySQL due to optimizations that WordPress makes specifically for MySQL and also the PG4WP plugin must have added some layer to process query to postgres that causes overhead process. However, this wasn’t really a problem, everything felt snappy enough for now.

Curious about how well my setup could handle traffic, I performed a stress test with 40 concurrent requests for 15 minutes using k6 benchmarking tool. The results were better than I expected: no crashes, no major slowdowns, and stable performance.

While the setup is stable, I know there’s always room for improvement. Here’s what I plan to do next:

  • Install a caching plugin: This should help reduce the load on the database by serving cached pages for repeat visitors.
  • Run benchmarks again: I want to see how much of a difference caching makes in both response times and resource usage.

If you’re dealing with similar constraints, this setup might be worth considering. With some creativity and a willingness to explore alternatives, you can get WordPress running even on a minimalist VPS!

Leave a Reply

Your email address will not be published. Required fields are marked *