How to optimize your Magento site’s server with log-cleaning automation — A Real-time Walkthrough
Case History |
---|
Issue: Poor server speed affecting the frontend user experience & load time |
Version: Magento Open Source & Adobe Commerce (Magento Enterprise) |
Root Cause: Increased server memory time |
Solution: Implementing log cleaning automation |
The Scenario
Built on Adobe Commerce (Magento Enterprise), our client’s eCommerce website faced the following challenges:
- Increasing Server Memory Usage
- Increased server memory time that hindered a series of processes associated with it
- Additional time required to read and write heavy-sized Magento log files
- Compromise in server speed.
- Adverse Effects on Customer Experience
- Reduced server speed affected customers’ frontend site navigation.
- Adverse impacts on the overall user experience.
How We Solved It:
Our Magento solution architects assessed the client’s website, server speed, performance, and overall health and devised a strategic plan to fix the above issues and drive optimal performance. The following steps were taken by our team:
-
Implementing Shell script
The extensive performance audit conducted by our team revealed that the primary root cause of the problem was uncleared log files which exacerbated the server issue. Our Magento solution architects recommended periodic cleaning of log files via ‘Shell script’ to fix this issue.
-
Automated and manual log cleaning
The shell script facilitates both manual and automated cleaning of Magento log files. In manual log cleaning, the script needs to be executed periodically or as and when required to clear the log files piled up over time. Alternatively, you can also schedule automated log cleaning as a daily cron job during non-business hours.
-
Cleaning both default and custom files
While executing the log deletion, the Shell script considers all log files placed under the Magento root directory/var/log folder. This includes both custom and default Magento logs like system.log, exception.log, payments.log, and other third-party log files.
- Daily archiving
By automated scheduling, the daily cron will run the shell script and clear the log files to reduce the overall file size, thereby maintaining the server speed. The previous day’s cleared log will be archived as a “.gz’ file and moved to the folder /backup.
- Auto-deletion of the archived files
The .gz files archived in the folder /backup will be automatically cleared once every 30 days.
By implementing the above steps, our team not only fixed the server issues but also gave the website speed and front-end performance a refreshing facelift.
A step-by-step guide to implementing the Shell script coding:
If you face similar problems and are looking for a solution, here’s the Shell script for log-cleaning automation that you can readily use:
1. Write a Shell script to clear the log and place this file in your Magento root directory. For instance, if you have named it “purge_log.sh”, here is the corresponding script:
Important note: Don’t forget to make the script executable.
chmod +x /var/www/html/purge_log.sh
2. To run the Shell script manually
- Login to the SSH terminal and connect your Magento server
- Navigate to the Magento root directory/
- Run the command sh purge-log.sh
3. To run the Shell script automatically (during the non-business hours)
- Set a cron job: 0 1 * * * /usr/bin/sh /var/www/html/purge_log.sh
The Result:
As you can see in the adjoining screenshot, there is a substantial improvement in server memory usage after executing the shell script.
Subsequently, the website showed improved performance in several aspects as listed below:
-
Enhanced front-end navigation:
By fixing the server memory issue, we drastically improved the website’s overall user experience. Right from the front-end navigation to seamless customer journey, the website’s end-to-end shopping experience got enhanced several folds, resulting in an applaudable increase in user engagement metrics like average time on page, average session duration, and pages per session.
-
Phenomenal increase in loading speed:
We restored the server to its nominal speed and performance, which improved the website’s loading speed in the front end. As a result of our meticulous optimization efforts, both mobile and desktop loading speeds hit nominal benchmarks.
This success story demonstrates how our technical prowess enabled our client to resolve and fix their awful user experience caused by server issues and log file discrepancies. If you want similar resolution and growth for your business, schedule a free discovery call with our Magento solution architects.
About the client:
Our client, Buy LED Online, is a leading electrical store specializing in fulfilling residential and commercial lighting needs with a spectacular selection of LED light bulbs. The brand sells LED bulbs, tubes, flat panels, track lighting, LED Solar Lights, recessed lighting, indoor and outdoor lighting for residential and commercial spaces, and much more. Catering to both household spaces and corporate offices, BuyLEDOnline has emerged as an undisputed leader in the LED lighting market.
- B2B (5)
- B2C (1)
- BigCommerce Development (7)
- COVID-19 (6)
- CRO (37)
- Digital Marketing (37)
- Drupal Solutions (3)
- Ecommerce (38)
- eCommerce Solutions (129)
- eCommerce Strategy (7)
- Holiday Season (18)
- Magento Development (48)
- Magento Maintenance (12)
- Magento Solutions (25)
- Marketing (4)
- Migration (2)
- Omnichannel (1)
- Shopify Development (22)
- The Commerce Shop News (15)
- Uncategorised (5)
- Uncategorized (16)
- Video (3)
- WooCommerce Development (3)
COMMENTS