Fetching page data & rendering components
Fetching page data & rendering components
Integrated Elasticsearch as the primary search & article data source for Beautyhaul, boosting Google PageSpeed Performance score from 29 to 69.
As the Beautyhaul content catalog expanded, legacy search and article listing endpoints relied on heavy MySQL SQL LIKE queries across multiple joined tables. Under high concurrent traffic, these queries locked read replicas and degraded the Google PageSpeed Performance score down to 29.
The goal was to shift public article data retrieval entirely from MySQL to Elasticsearch 8, powered by instant SQS + Lambda real-time updates and a 2x daily CLI fail-safe backup.
// CLI Fail-Safe Batch Upsert Loop (100 Articles per Iteration)
for {
// 1. Fetch 100 articles from MySQL using cursor pagination / timestamp filter
articles, err := fetchArticleBatch(db, lastID, batchSize) // batchSize = 100
if len(articles) == 0 || err != nil {
break // Batch complete
}
// 2. Perform bulk upsert to Elasticsearch blog index
err = esClient.BulkUpsert(ctx, "beautyhaul_blog_articles", articles)
// 3. Advance cursor for next batch iteration
lastID = articles[len(articles)-1].ID
}
Security & Sanitization Note: Architectural parameters, metrics, and code snippets above have been generalized and sanitized to protect proprietary corporate infrastructure while representing exact real-world engineering methodologies.