Bagisto, is an open source eCommerce platform built on Laravel. It is designed to be flexible, strong, and ready to support growing businesses.
As product catalogs expand into the millions, maintaining high performance becomes a critical factor.
This blog explores advanced strategies to scale Bagisto for managing 10 million products, focusing on database optimization, caching, and efficient queue management.
Understanding the Challenges
When scaling an eCommerce store to handle millions of products, the challenges evolve as the product catalog grows.
With around 0.2 million products, the system performs smoothly, handling database queries and searches efficiently without the need for advanced optimizations.
At 10 million products, the database and search face heavy load, so advanced tools like Elasticsearch and optimized caching are needed to maintain stable performance.
Key Challenges:
- Database Performance – Handling a massive volume of records efficiently without slowing down the system.
- Search Optimization – Ensuring that users can quickly find products, even with such a large catalog.
- Indexing & Caching – Reducing load times and improving response speed with proper indexing strategies and caching mechanisms.
Let’s explore how Bagisto, built on Laravel, handles these challenges and scales efficiently.
Database Performance in Bagisto
Bagisto uses MySQL/MariaDB by default, and to handle 10 million products efficiently, we need to optimize both the database and the way the platform interacts with it.
Optimizing Database Queries in Bagisto
Bagisto uses Eloquent ORM for database queries, simplifying database interaction, but with large datasets it can slow down. To improve performance, optimization is needed.
- Eager Loading: Avoid N+1 query problems by using eager loading for relationships. This ensures that related models are loaded in a single query, eliminating the need for multiple queries.
- Batch Updates: When updating large sets of records (e.g., updating product prices or inventory), use batch processing to handle them in chunks, reducing the load on the database.
Indexing Strategies in Bagisto for Scalable Database Performance
Bagisto structures indexed data for efficient search and retrieval, storing product information in Elasticsearch as documents within indices.
Each document in an index represents a product or product-related data (like product name, price, description, etc.).
This structured approach allows Elasticsearch to efficiently manage and retrieve product information.
When a user searches in Bagisto, Elasticsearch scans indexed data to deliver fast, accurate results, improving search speed and enhancing the overall user experience.
To enhance Bagisto performance, the following indexers play a crucial role:
-
Price Indexing: In Bagisto, price indexing keeps product prices accurate and up-to-date by updating the database whenever changes occur, ensuring consistent storefront pricing.
-
Inventory Indexing: In Bagisto, inventory indexing keeps product stock levels accurate by updating quantities in real time.
Bagisto automatically updates inventory when customers buy, return, or restock products, ensuring accurate stock display and consistent pricing rules.
- Flat Indexing: Flat indexing is a mechanism that optimizes product data retrieval. By processing products in batches, the system can handle large datasets efficiently without overloading the server. It’s particularly useful for managing large volumes of product attributes (e.g., SKU, price, weight) for various channels and locales.
- Catalog Rule Indexing: Catalog rule indexing updates product prices based on changes in catalog rules, such as expiring or modified offers. Bagisto schedules this indexing process daily at 00:01, ensuring that pricing remains accurate without requiring manual intervention.
-
ElasticSearch: Elasticsearch manages large data volumes and provides fast, scalable search results. Bagisto uses it to index products, greatly improving search performance.
Leveraging Elasticsearch for Scalable Search
One of the most critical components of scaling an eCommerce platform is ensuring that product search functionality remains fast and efficient, even with millions of products.
While MySQL/MariaDB handles basic queries, they struggle with full-text search and complex filtering on large catalogs, which is where Elasticsearch excels.
1. Why Elasticsearch?
Elasticsearch is a fast, scalable search engine with strong full-text search features. Integrating it with Bagisto helps deliver better search performance and results.
- Full-Text Search: Elasticsearch provides powerful full-text search capabilities, making it faster and more efficient than relational databases.
- Scalability: With its distributed architecture, Elasticsearch can scale horizontally by adding more nodes.
- Real-Time Indexing: When products are added, updated, or removed, Elasticsearch allows for real-time indexing. This ensures that product searches reflect the most up-to-date information, crucial for a dynamic e-commerce environment.
Integrating Elasticsearch for Bagisto helps search performance scale smoothly as the product catalog continues to grow.
2. Integrating Elasticsearch with Bagisto
Integrating Elasticsearch with Bagisto is straightforward. First, configure your Elasticsearch instance and connect it through the admin panel.
Bagisto will automatically index products, including attributes like name, description, price, and availability.
Here’s a simple configuration for integrating Elasticsearch with Bagisto:
To configure Elasticsearch, please refer to the Configuration Setup documentation.
3. Real-Time Indexing and Synchronization
Elasticsearch indexes products in real-time, ensuring that Bagisto instantly reflects additions or updates.
This keeps product searches up-to-date, which is crucial in eCommerce environments where product information changes frequently.
- How Real-Time Indexing Works in Bagisto: When a product is updated in Bagisto—whether it’s a price change, stock update, or a new product—Elasticsearch quickly updates the search index.
This ensures customers always see the latest prices and availability in search results, improving their shopping experience. - Automatic Re-Indexing in Bagisto: Bagisto automatically updates Elasticsearch whenever products are added, updated, or deleted. This keeps search results accurate and in sync with the latest product data. Without this, users might see outdated prices or stock levels.
4. Final Performance Benchmark
Here’s a final benchmark of search performance and page load time after implementing Elasticsearch.
The image shows that the Home page loads in around 585.16 milliseconds with the 10 million products.
In the image below, you can see the Home page load time is around 561 milliseconds with the 10 million products.
In the below image below, you can see the category page load time around 516 milliseconds with the 10 million products.
Watch this video to scale your eCommerce project for massive growth without sacrificing speed or user experience.
Conclusion: Future Scalability Beyond 10 Million Products
Scaling Bagisto to handle 10 million products is a challenging but achievable task.
By optimizing the database with eager loading and batch updates, and integrating Elasticsearch for fast, real-time search, you can improve your store’s performance.
Leveraging advanced caching techniques further ensures that your Bagisto-powered store remains fast and responsive, even as the product catalog grows.
If you need custom solutions, hire a Laravel developer to build features for your store. Explore more Bagisto extensions and tools on the official Bagisto website.
