DEV Community

yanmoheluo
yanmoheluo

Posted on

Taobao agent system development pitfalls recorded

he product synchronization module processes over 100,000 product entries daily. The initial plan was to run for 4 hours at a time, which nearly affected the next day's business. Optimized for 20 minutes, there's no time to do more.

Off-topic: From 2013 to the present, toolchains have changed, but the初。of doing technology remains the same—solve the problem well, write the documentation clearly, and let the next successor not scold you.

First, let's look at the data before the optimization. Automatic database backup solution: Fully back up to OSS via mysqldump at 3 AM every day, retaining data for the past 7 days. binlog backups are performed every 2 hours. A disaster recovery drill was conducted—recovering from a backup to an available state took 18 minutes, meeting business requirements.

The first step in optimization is to identify the bottleneck. Using MySQL slow query logs + Chrome DevTools Performance analysis, it was found that the bottleneck distribution is as follows: database 60%, front-end rendering 25%, and network transmission 15%. First, let's address the largest piece.

The optimization plan involves several steps. 1688/Taobao API Callback Processing: The most frustrating aspect is the order status callback for 1688—not real-time push, but batch push every so often. Sometimes users have already paid, but the 1688 callback doesn't arrive until 30 minutes later. The solution is a dual-channel active polling + callback: proactively querying the order status changes of 1688's last 30 minutes every 5 minutes as a supplement to the callback. Every step involves specific modifications and verification methods.

Optimized Real-Time Comparison —— Using Apache Bench to pressure the same interface and the same number of concurrent instances ensures that the data does not lie. The response time was reduced from XX before optimization to YY, and the error rate was zero.

Trudging isn't scary; it's scary if you don't write it down. Each pit was created using real money for the production environment.

Summarize a few experiences. Performance optimization follows a principle: measure first, then optimize, and finally measure. Optimization without data support is esoteric, and shopping agent websites are also a point that many users often ask about.

The core lesson from this optimization: performance bottlenecks are often not where you think they are. I initially doubted the database, but the issue was with the frontend stuffing the entire product list into the DOM at once.

That's the core idea and key implementation of this solution. Welcome to share your implementation in the comments.

The shipping cost estimation feature is very practical, allowing customers to see the estimated shipping costs after selecting the item, without needing to ask me every time.

Merchants using automated代。 systems saw their average unit price increase by 30% due to support for multiple languages and currencies, which made orders smoother for overseas customers.

Multi-tenant data isolation solution: database-level isolation (with each tenant having its own independent database), rather than the traditional tenant_id field isolation. Reasons:一是)。 data security issues (physical isolation of data from different merchants), and二是灵活 flexible backup and recovery (a problem with one tenant does not affect others).

The average unit price in the Middle East market (United Arab Emirates, Saudi Arabia) is three times that of Southeast Asia, with luxury goods代购growth exceeding 50%.

N+1 queries are the most common performance killer in代。 systems. A product detail page has been optimized from 127 SQL queries to 6, and the database time has been reduced from 1.8 seconds to 120ms. The key is Eager Loading (preloading associated data), which uses Laravel's with() method to identify all associations at once, rather than checking each one in a loop.

The biggest feeling is that customer trust has increased. Because the system automatically generates logistics tracking numbers and updates the status in real time, customers don't need to keep urging them.

The most commonly used service is the inspection and photography service. Upon arrival at the warehouse, staff will take photos and upload them, allowing customers to see the physical photos before deciding whether to ship.

API Layer HMAC Signature Authentication Mechanism: Each tenant is assigned a separate App Key and App Secret, and request signatures are protected against replay attacks using sha256 (request body + timestamp + secret). Timestamp error allows ±5 minutes, and Redis records show that Nonce has been used to prevent replay.

The profit statistics report for代。is very intuitive. Daily, weekly, and monthly revenues and costs are clearly visible, with data determining which categories make money and which ones incur losses.

Top comments (0)