Tokopedia promo platform: cashback, discounts and tiered benefits
Led the two backend teams behind Tokopedia’s promo platform: one engine for cashback, discounts and multi-tier benefits that scaled from hundreds of requests per second to more than 10,000 on sale days, and sent out 5M+ coupons a day.
Role
Lead Software Engineer, Promo Platform Core & Promo Automation
Promotions that hold up on the busiest days of the year
Promotions are one of Tokopedia’s main levers for buyer growth: cashback, discounts and benefits that change with the buyer’s tier. They also run when traffic is highest: the payday campaign that starts on the 25th of every month and lasts three to four days, and twin-date sales such as 11.11 and 12.12.
On a normal day the platform handled hundreds of requests per second. During a campaign, that rose to more than 10,000. Every promo still had to be applied correctly and stay within its quota.
The busiest minutes of a sale are when a promo bug costs the most.
01Peak traffic. From hundreds of requests per second to more than 10,000, several times a month.
02Many promo types. Cashback, discounts and multi-tier benefits, each with its own rules.
03Budget control. Every promo had a quota, and usage had to be counted exactly, once per order.
04Reaching buyers. Coupons had to reach the right buyers without each buyer claiming them one by one.
My role
Leading the promo platform teams
I was Lead Software Engineer for the Promo Platform Core and Promo Automation teams from January 2020 to May 2022, after joining Tokopedia as a Software Engineer in 2017. I managed the engineering process for both teams, set the roadmap, and designed new flows and the technical architecture for Buyer Growth and the Promotion Platform.
01Teams. Promo Platform Core had 5 backend engineers and Promo Automation had 4. Three SDETs worked across both teams.
02Hands-on. Developed the cashback and discount calculation logic and the multi-tier benefit promo system.
03Stakeholders. Coordinated with Business, Product, Technology and other stakeholders, inside and outside Tokopedia.
Approach
How we built it
1. One promo engine
Discounts and cashback weren’t separate systems; they were types of promo rule. One engine evaluated every promo, and each promo type was a component inside it.
2. Ready for peak
On sale days the platform scaled horizontally. We tuned caching so that no process depended on the database directly, which let the same system go from hundreds to more than 10,000 requests per second.
3. Quotas
Every promo had a quota. Each order carried a unique order ID, and a usage counter in Redis tracked how much of each promo had been used.
4. Automatic coupons
The Promo Automation team distributed coupons automatically based on user characteristics, so buyers didn’t have to claim them by hand. On a normal day that was more than 5 million coupons.
5. Stack
Go, PostgreSQL and Kafka pub/sub, with Grafana, Kibana, Elasticsearch, Datadog and New Relic for monitoring.
Simplified promo flow. The engine and quota check read from cache and Redis, never from the database directly.
Key decisions
Trade-offs we made on purpose
Decision 01
Keep the database off the request path
We scaled horizontally and tuned caching so no process depended on the database directly. That is what let the platform go past 10,000 requests per second.
Trade-off: The cache had to stay in sync with the promo config in PostgreSQL.
Decision 02
Operational tools later
We built the promo engine and coupon distribution first, and the operational tools afterwards.
Trade-off: Until the tools arrived, promo configs had to be set manually in the database.
Outcome
What changed
10k+
Requests per second at peak, up from hundreds on a normal day
5M+
Coupons distributed automatically a day
1
Engine for cashback, discounts and multi-tier benefits
The platform carried every payday and twin-date campaign from 2020 to 2022 without a sale day going wrong, and buyers got their coupons without having to claim them.
What I learned
What I’d keep, and what I’d change
Operational tools came late here, and until they did, promo configs were set by hand in the database. It’s a lesson I took with me to Pintu Pro: build the operational tools from day one.