Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaranvpl authored Nov 9, 2023
1 parent b02612b commit 00dd957
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/docs/en/nats/jetstream/pull.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

## Overview

**NATS JetStream** supports two various way to consume messages: **Push** and [**Pull**](https://docs.nats.io/using-nats/developer/develop_jetstream/consumers#push-and-pull-consumers){.external-link targer="_blank} consumers.
**NATS JetStream** supports two various way to consume messages: [**Push** and **Pull**](https://docs.nats.io/using-nats/developer/develop_jetstream/consumers#push-and-pull-consumers){.external-link targer="_blank} consumers.

**Push** consumer is using by default to consume messages with the **FastStream**. It means, that **NATS** server delivers messages to your consumer as far as possible by itself. But also it means, that **NATS** should control all current consumer connections and increase server load.
The **Push** consumer is used by default to consume messages with the **FastStream**. It means that the **NATS** server delivers messages to your consumer as far as possible by itself. However, it also means that **NATS** should control all current consumer connections and increase server load.

Thus, **Pull** consumer is a recommended by *NATS TEAM* way to consume JetStream messages. Using it, you just asking **NATS** for a new messages with a some interval. It sounds a little bit worse than the automatic message delivery, but it provides you with a several advantages:
Thus, the **Pull** consumer is the recommended way to consume JetStream messages by the *NATS TEAM*. Using it, you simply ask **NATS** for new messages at some interval. It may sound a little less convenient than automatic message delivery, but it provides several advantages, such as:

* consumer scaling without *queue group*
* handle messages in batches
* reduce **NATS** server load
* Consumer scaling without a *queue group*
* Handling messages in batches
* Reducing **NATS** server load

So, if you want to consume a huge messages flow without strict time limitations, **Pull** consumer is the right choice for you.
So, if you want to consume a large flow of messages without strict time limitations, the **Pull** consumer is the right choice for you.

## FastStream details
## FastStream Details

**Pull** consumer is just a regular *Stream* consumer, but with the `pull_sub` argument, controls consuming messages batch size and block interval.
The **Pull** consumer is just a regular *Stream* consumer, but with the `pull_sub` argument, which controls consuming messages with batch size and block interval.

```python linenums="1" hl_lines="10-11"
{!> docs_src/nats/js/pull_sub.py !}
```

Batch size doesn't mean that your `msg` argument is a list of messages, but it means, that you consume up to `10` messages for one request to **NATS** and call your handler per each message in an `asyncio.gather` pool.
The batch size doesn't mean that your `msg` argument is a list of messages, but it means that you consume up to `10` messages for one request to **NATS** and call your handler for each message in an `asyncio.gather` pool.

So, your subject will be processed much faster, without blocking per message processing. But, if your subject has less than `10` messages, your reguest to **NATS** will be blocked for `timeout` (5 seconds by default) trying to collect required messages amount. So, you should choise `batch_size` and `timeout` accurately to optimize your consumer efficiency.
So, your subject will be processed much faster, without blocking for each message processing. However, if your subject has fewer than `10` messages, your request to **NATS** will be blocked for `timeout` (5 seconds by default) while trying to collect the required number of messages. Therefor, you should choose `batch_size` and `timeout` accurately to optimize your consumer efficiency.

0 comments on commit 00dd957

Please sign in to comment.