Client: Amplereads
The Challenge
Before the migration, Amplereads was facing a number of serious issues in their codebase and database operations:
- Multiple developers working in parallel, often overlapping, with little or no documentation.
- Large numbers of bugs accumulating because of code that was hard to debug or understand.
- Use of less experienced developers who inadvertently introduced inefficiencies, especially in database operations, leading to spikes in load and latency.
- Database was not optimized: unindexed queries, redundant data, inconsistent schema, no sanitization of data, bloated tables, etc.
Together, these problems were causing performance degradation, unpredictable behavior, and making development slower and riskier.
The Solution
To address these issues, the following steps were taken
- Migrated the codebase from Laravel 6.x to 12.x
- Upgraded all dependencies to compatible versions.
- Refactored deprecated features and methods.
- Ensured compatibility with latest PHP versions, security patches, etc.
- Created a specific script to sanitize the data in the DB
- Removed duplicate, corrupt, or inconsistent entries.
- Fixed malformed data, removed obsolete or unused tables/columns.
- Standardized formats (e.g., date formats, names, foreign key relations).
- Migrated the sanitized data into the upgraded, optimized schema
- Introduced improved schema design: added indexes, optimized relationships, normalized where needed.
- Ensured data integrity, preserved important history but removed or archived what was not needed.
- Optimized the database operations
- Identified slow queries, added appropriate indices.
- Reworked queries to be more efficient (e.g. batch operations, reducing N+1 problems).
- Configured caching where possible.
- Addressed code performance
- Introduced unit and integration tests around critical components to prevent regressions.
- Refactor of inefficient code paths, pruning of legacy or unused code.
- Improved error handling and logging to help catch issues early.
Results Delivered
The outcomes of the migration and optimization were very positive:
| Metric | Before | After / Improvement |
| Code performance (response times, throughput) | Poor in many endpoints; some operations suffered queueing and timeouts | Over 40% improvement in overall code performance (faster API responses, reduced latency) |
| DB load / Spikes | Frequent spikes under moderate load; slow query bottlenecks | DB spikes essentially disappeared; load is more stable and predictable |
| Bug count / Maintenance cost | High bug burden; issues arising from undocumented code, inconsistent data | Reduced number of bugs; easier debugging; faster feature development |
| Developer productivity | Slower due to unclear code, inconsistent schema | Faster onboarding; clearer code paths; less time spent fixing regressions |
| System reliability & stability | Unstable under load; risk of data corruption or performance collapse | More robust under load; less risk; improved scalability |
Technology Stack
The migration and optimization were carried out using:
- Framework: Laravel 12.x (migrated from 6.x)
- Language: PHP 8.2
- Database: MySQL 8 / MariaDB (optimized with new schema, indexing, caching strategies)
- Caching: Redis for session and query caching
- Version Control: Git with branching strategy for safe migration
- Server Environment: Nginx + PHP-FPM, running on a Linux environment
- Testing: PHPUnit & Laravel Dusk for unit and integration testing
- Monitoring & Logs: Laravel Telescope, custom logging, and server monitoring tools
Key Takeaways & Recommendations
- Documentation matters: Even if code is working, lack of documentation increases risk and slows down everyone.
- Data hygiene is critical: Sanitizing data before migrating ensures you don’t carry forward inefficiencies or corrupted data into the new system.
- Incremental upgrades + testing: Migrating version-by-version and writing tests around critical flows helps contain risk.
- Optimize DB early: Indexes, normalized schema, avoiding N+1 queries, batch operations — these pay off immediately.
- Skilled developers on core parts: Problem areas (database, performance-sensitive code) should always be handled or reviewed by experienced developers to prevent long-term issues.