Debugging Slow Update Calls in a Microservice Backend: Analysis and Fixes
After a recent deployment a backend update operation became extremely slow, revealing RPC retry, thread‑pool misconfiguration, and row‑lock contention between services, which were analyzed and resolved through thread‑pool tuning and transaction separation.
Problem description: After a recent deployment, a backend update operation became extremely slow, taking up to 10 seconds and causing performance concerns.
Analysis: Log tracing revealed two RPC calls with retry=1, leading to duplicate updates; the update statement uses a primary‑key but still takes long. Investigation showed row‑lock contention between Service A and Service B, with asynchronous tasks sometimes running in the original thread due to a thread‑pool failure strategy. The thread‑pool configuration caused insufficient threads and unexpected execution paths.
Code snippet of the problematic update:
update table set a=#{1},b=#{2},... where id=#{0} (id primary key)Solution: Adjust thread‑pool parameters (set core and max threads equal, increase queue size to 9999) to ensure sufficient threads, remove retry for write operations, and separate the transaction from the Service A → Service B call to avoid lock contention. Two implementation options are presented: an ideal full microservice refactor and a practical immediate fix.
Summary: The root cause was RPC retry combined with thread‑pool misconfiguration causing lock competition; fixing the thread pool and eliminating unnecessary retries restored normal performance.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
