ydb-platform / ydb-platform/ydb-python-sdk

Performance Degradation in Python SDK (v3.18.2) When Reading High-Load YDB Topic

Open
#670 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
102
Forks
75
Avg merge
1d 23h
Merged PRs (30d)
13

Description

Bug Report

YDB Python SDK version:
3.18.2

Environment:

  • 24 parallel reader processes.
  • Topic with 2000 partitions
  • High write load (spikes of 40k+ messages/sec).

Current behavior:

  • Read throughput drops by ~33% (from ~30k to ~20k messages/sec) during high write loads.
  • Performance degradation persists until write load stabilizes.
  • No issues observed with the C++ SDK under identical conditions.

Expected behavior:

  • Python SDK should maintain stable read throughput (~30k messages/sec) regardless of write load, matching the C++ SDK’s performance.

Steps to reproduce:

  1. Configure a YDB topic with 2000+ partitions.
  2. Use Python SDK (v3.18.2) to read the topic with 24 parallel processes.
  3. Generate a sustained high write load (e.g., 40k+ messages/sec).
  4. Observe read throughput degradation in Python SDK while the C++ SDK remains stable.

Related code:

# Reader initialization  
async def init_client(self):  
    reader = self._ydb_driver.topic_client.reader(  
        topic=ydb.TopicReaderSelector(path=self._topic, partitions=self._partition_groups),  
        consumer=self._consumer_id,  
    )  
    self._reader = reader  

# Batch processing  
async def read_topic_partition(self) -> typing.List[typing.Tuple[datatypes.PublicMessage, int]]:  
    ...  
    events_batch = await asyncio.wait_for(  
        self._reader.receive_batch(max_messages=self._max_messages),  
        timeout=_CLIENT_TIMEOUT,  
    )  
    ...  

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the related reader initialization and receive_batch code in the report, then reproduce the workload using 2,000+ partitions, 24 parallel reader processes, and sustained 40k+ messages/sec writes. Compare Python and C++ throughput and trace the Python reader path to identify why reads fall from about 30k to 20k messages/sec; done means stable Python throughput under the reported load.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.