Skip to content

Commit

Permalink
Lower the flow control defaults, remove psutil dependency (googleapis…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored Apr 27, 2018
1 parent c7b9231 commit df55846
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
9 changes: 7 additions & 2 deletions pubsub/google/cloud/pubsub_v1/subscriber/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,13 @@ def subscribe_experimental(
the callback during processing, the exception is logged and the message
is ``nack()`` ed.
The ``flow_control`` argument can be used to control the rate of
message processing.
The ``flow_control`` argument can be used to control the rate of at
which messages are pulled. The settings are relatively conservative by
default to prevent "message hoarding" - a situation where the client
pulls a large number of messages but can not process them fast enough
leading it to "starve" other clients of messages. Increasing these
settings may lead to faster throughput for messages that do not take
a long time to process.
This method starts the receiver in the background and returns a
*Future* representing its execution. Waiting on the future (calling
Expand Down
15 changes: 7 additions & 8 deletions pubsub/google/cloud/pubsub_v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

from __future__ import absolute_import
import collections
import psutil
import sys

from google.api_core.protobuf_helpers import get_messages
Expand Down Expand Up @@ -58,13 +57,13 @@
'max_lease_duration'],
)
FlowControl.__new__.__defaults__ = (
psutil.virtual_memory().total * 0.2, # max_bytes: 20% of total RAM
float('inf'), # max_messages: no limit
0.8, # resume_threshold: 80%
100, # max_requests: 100
100, # max_request_batch_size: 100
0.01, # max_request_batch_latency: 0.01s
2 * 60 * 60, # max_lease_duration: 2 hours.
100 * 1024 * 1024, # max_bytes: 100mb
100, # max_messages: 100
0.8, # resume_threshold: 80%
100, # max_requests: 100
100, # max_request_batch_size: 100
0.01, # max_request_batch_latency: 0.01s
2 * 60 * 60, # max_lease_duration: 2 hours.
)


Expand Down
1 change: 0 additions & 1 deletion pubsub/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
dependencies = [
'google-api-core[grpc]<2.0.0dev,>=0.1.3',
'grpc-google-iam-v1<0.12dev,>=0.11.1',
'psutil<6.0dev,>=5.2.2',
]
extras = {
}
Expand Down

0 comments on commit df55846

Please sign in to comment.