Back to articles
Technology Insight

Optimizing VPS for E-commerce: LiteSpeed + LSCache + Object Cache Configuration to Handle 10k Orders/Day on a 4GB Server

May 19, 2026

Introduction: The Challenge of Scaling E-commerce on a Budget

In today's competitive e-commerce landscape, website performance directly impacts conversion rates, customer satisfaction, and ultimately, revenue. Studies consistently show that even a one-second delay in page load time can reduce conversions by 7%. For growing online stores, the infrastructure cost can quickly spiral, especially when relying on expensive managed hosting or cloud platforms. However, with strategic software configuration, it is entirely possible to run a high-traffic e-commerce operation on modest hardware. This guide details a proven stack—centered on LiteSpeed Web Server, LSCache, and Redis Object Cache—capable of handling over 10,000 orders per day on a Virtual Private Server (VPS) with only 4GB of RAM. This approach offers enterprise-grade performance at a fraction of the typical cost.

Why the LiteSpeed Ecosystem is a Game-Changer for E-commerce

Traditional stacks using Apache or Nginx with PHP-FPM can struggle under the dynamic, database-heavy load of an e-commerce site. LiteSpeed Web Server (LSWS) presents a superior alternative, particularly when paired with its built-in caching engine.

Key Advantages of LiteSpeed

  • Event-Driven Architecture: Unlike Apache's process-based model, LSWS is event-driven, similar to Nginx, but with native PHP processing (LSPHP). This eliminates the overhead of communicating with a separate PHP-FPM service, reducing memory usage and latency.
  • Built-in Full-Page Cache (LSCache): This is the cornerstone of performance. LSCache operates at the web server level, serving cached pages almost as fast as static files. For e-commerce, its ability to handle private cache for user-specific content (like cart pages) and public cache for product pages is critical.
  • HTTP/3 and QUIC Support: Modern protocol support improves load times, especially on mobile networks and for users with higher latency.
  • Compatibility: LSWS is a drop-in replacement for Apache, using the same .htaccess syntax, which simplifies migration from shared hosting environments.

Core Architecture: Building the 4GB VPS Stack

The goal is to maximize the utility of limited RAM. Every service must be finely tuned.

1. Server Specifications & Base Setup

Start with a reputable VPS provider offering high-frequency CPUs and NVMe storage. A configuration like 2 vCPU cores, 4GB RAM, 80GB NVMe SSD is sufficient. Install a minimal, stable OS like Ubuntu 22.04 LTS or AlmaLinux 9.

2. LiteSpeed Web Server & LSPHP Installation

Install the OpenLiteSpeed version for cost-efficiency or the Enterprise edition for advanced features. Pair it with the matching LSPHP version, compiled with optimizations for your CMS (e.g., WordPress with WooCommerce). Key PHP settings:

  • memory_limit = 256M (Adequate for most operations when caching is effective)
  • max_execution_time = 120 (For longer-running processes like order exports)
  • opcache.enable=1 & opcache.memory_consumption=128 (Crucial for PHP bytecode caching)

3. MariaDB/MySQL Database Optimization

The database is often the bottleneck. On a 4GB server, allocate carefully.

  • Innodb Buffer Pool: Set innodb_buffer_pool_size = 1G. This is the most important setting, determining how much data/MariaDB can cache in RAM.
  • Connection Limits: Reduce max_connections to 50-70 to prevent memory overload from idle connections.
  • Query Cache: Disable it (query_cache_type = 0). It's deprecated in newer versions and is inefficient under high write loads typical of e-commerce.
  • Use a tool like mysqltuner.pl to analyze and recommend further settings.

Implementing the Caching Strategy: LSCache + Object Cache

Caching is multi-layered. LSCache handles full HTML pages, while an object cache stores database query results.

Configuring LSCache for WooCommerce/Dynamic Content

Out-of-the-box, LSCache can't safely cache logged-in pages or pages with carts. The LiteSpeed Cache Plugin (for WordPress) provides granular control.

  • Public Cache: Enable for product pages, categories, blogs. Set TTL (Time-To-Live) to 6-12 hours.
  • Private Cache: Enable for "My Account", "Cart", and "Checkout" pages. This caches the page structure but excludes personal data, served per user.
  • ESI (Edge Side Includes): This advanced feature allows parts of a page to be uncached. For example, the header cart counter can be fetched dynamically via ESI while the rest of the product page is served from public cache.
  • Cache Exclusion Rules: Always exclude the checkout process, admin area, and any order confirmation pages from caching.

Integrating Redis for Object Caching

While LSCache stores the final HTML, WordPress still generates many database queries to build that page. Redis Object Cache stores the results of these queries in RAM.

  1. Install and start the Redis server on localhost. Limit its memory usage: maxmemory 512mb and set maxmemory-policy allkeys-lru.
  2. Install the Redis Object Cache plugin for WordPress and enable it. This bypasses the database for repeated queries.
  3. The synergy is powerful: A visitor requests a product page. LSWS serves the full HTML from LSCache. If the cache is empty but warm, WordPress generates the page, fetching data from Redis instead of MySQL, and then stores the final HTML in LSCache for the next visitor.

Performance Impact: A well-configured stack can reduce Time-To-First-Byte (TTFB) from 800ms to under 50ms for cached pages and cut database load by over 90%.

Advanced Tuning for Peak Traffic & Order Processing

Handling Checkout and Payment Gateways

The checkout flow must be uncached but still optimized.

  • Use a dedicated, uncached PHP handler for the /checkout/ and /wc-api/* (payment callback) endpoints to ensure stability.
  • Implement a queuing system for non-critical tasks (e.g., sending order confirmation emails, updating stock in external systems). A simple solution like the Action Scheduler library (bundled with WooCommerce) is excellent.

Monitoring and Maintenance

Proactive monitoring is key to preventing downtime during sales.

  • Use NetData or a lightweight agent for real-time monitoring of CPU, RAM, disk I/O, and web server connections.
  • Set up log rotation for LSWS and MariaDB logs to prevent disk fill-up.
  • Schedule cache pre-warming before anticipated traffic surges (e.g., a marketing email blast) using a crawling tool.

Security and Reliability Considerations

Performance is meaningless without stability and security.

  • Firewall: Configure UFW or firewalld to allow only ports 80, 443, and SSH.
  • Brute Force Protection: Utilize LiteSpeed's built-in reCAPTCHA integration and rate-limiting for login pages.
  • Backups: Implement automated, off-server backups for the database and website files. The 4GB constraint makes local backups risky.
  • Failover Plan: Have a scaled-up server image ready to deploy if traffic consistently exceeds capacity, signaling it's time to upgrade.

Conclusion: Achieving Enterprise Scale on a Startup Budget

Optimizing a VPS for high-traffic e-commerce is not about throwing more resources at the problem, but about intelligently leveraging software to do more with less. The LiteSpeed, LSCache, and Redis stack represents a paradigm shift, transforming a $20-30/month VPS into a robust platform capable of supporting a business processing millions in revenue. The initial investment in configuration pays continuous dividends through reduced hosting costs, superior customer experience, and improved resilience during traffic peaks. By following this architecture, online store owners can confidently scale their operations, knowing their infrastructure is both performant and cost-effective.