Skip to content

DictationTranscriber default max_workers = cpu_count-1 serializes concurrent open_live() sessions on 1-2 vCPU hosts #302

Open

Description

@YashasviThakur

Found by reading the code (not executed): DictationTranscriber.__init__ in assemblyai/dictation/v1/client.py defaults max_workers to max(1, os.cpu_count() - 1).

Every open_live() session submits _impl.transcribe_live to that pool and holds one worker thread for the entire recording, but the work is network I/O, not CPU. On a 1-2 vCPU container (small Cloud Run/Fargate/Lambda sizes, CI runners) the pool has one worker, so:

  • the second concurrent open_live() does not start its HTTP request until the first session completes (standard ThreadPoolExecutor queueing);
  • its write() calls only fill the in-memory queue, so all of its audio is uploaded late and its latency becomes the first dictation's full duration plus its own;
  • the server-side "upload went silent" timeout and 120 s cap only start counting once a session actually begins, so failures show up late and far from the cause.

Dictation backends serving several users at once are exactly the use case in the docs ("a telephony media stream", "a WebRTC track").

Suggested fix: default to an I/O-appropriate size such as min(32, (os.cpu_count() or 1) + 4) (what ThreadPoolExecutor itself uses), and/or warn when open_live() is called while all workers are busy. AsyncDictationTranscriber is unaffected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions