In distributed TensorFlow, is it possible to share the same queue across different workers?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
In older TensorFlow 1.x systems, queue-based input pipelines were a common way to feed data into training jobs. In distributed training, a natural question is whether several workers can consume from the same queue. The short answer is yes in some TensorFlow 1.x graph setups, but it is usually not the design you want, and in modern TensorFlow 2 the preferred answer is to use tf.data sharding or data services instead of shared queues.
What “Shared Queue” Means in TensorFlow
In TensorFlow 1.x, a queue such as FIFOQueue or RandomShuffleQueue is a stateful resource in the graph. If that queue is placed on one task and multiple workers can reach it, those workers can enqueue or dequeue from the same shared resource.
Conceptually, that means the queue is not copied per worker. It lives in one place, and remote workers interact with it through the distributed graph.
That makes sharing possible, but it also introduces central coordination and network traffic.
Why a Shared Queue Is Usually a Bad Fit
A single shared queue can become:
- a bottleneck, because all workers contend for one resource
- a single point of failure, because if the hosting task dies, input stalls
- a source of uneven throughput, because faster workers may consume more aggressively than slower ones
- harder to debug than local worker pipelines
Distributed training generally scales better when each worker reads its own shard of the dataset instead of fighting over one central queue.
Modern TensorFlow Approach: Shard the Dataset
In TensorFlow 2, tf.data is the standard input pipeline API. Instead of manually managing queues, each worker typically gets its own dataset shard.
This avoids central queue contention and makes it obvious which worker reads which slice of the data.
Distributed Training with MultiWorkerMirroredStrategy
A common modern pattern is to build the dataset once and let TensorFlow distribute it with worker-aware sharding.
In practice, you combine this with dataset options or file-based sharding so workers do not all read the exact same examples unless that is intentional.
If You Are Stuck on TensorFlow 1.x
If you are maintaining an older graph-based system, then yes, a shared queue can be placed on a device such as a parameter-server task or another designated host. Multiple workers can dequeue from it. But you need to think through capacity, coordination, and failure behavior.
In many TF1 deployments, engineers eventually moved away from a single shared queue because scaling and operability were poor compared with per-worker readers.
Common Pitfalls
- Assuming “possible” means “recommended” for distributed input design.
- Building a single queue that becomes the training bottleneck.
- Forgetting fault tolerance when the queue resource lives on one remote task.
- Letting workers read overlapping data unintentionally.
- Using queue-based TF1 designs for new TensorFlow 2 code instead of
tf.data. - Ignoring dataset sharding and then wondering why scaling is poor.
Summary
- In TensorFlow 1.x, multiple workers can technically share one queue resource in a distributed graph.
- That design is usually harder to scale and operate than per-worker input pipelines.
- In TensorFlow 2, prefer
tf.data, dataset sharding, or data services. - Shared queues centralize coordination and can become bottlenecks.
- Choose an input pipeline design that scales with worker count instead of concentrating traffic in one place.
Related reading
- In Keras, what exactly am I configuring when I create a stateful LSTM layer with N units?
- In Keras what is the difference between Conv2DTranspose and Conv2D
- In TensorFlow 2.0 with eager-execution, how to compute the gradients of a network output wrt a specific layer?
- In tensorflow distributed mode, there is something weird run in one ps - one worker
- In gbm multinomial dist, how to use predict to get categorical output?
- In machine learning, what is definition of “downstream”?
- In Kafka Connect, how to connect with multiple kafka clusters?
- In Kafka HA, why minimum number of brokers required are 3 and not 2

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.