Skip to content

pubsub: start connections slowly#2055

Merged
pongad merged 2 commits intogoogleapis:masterfrom
pongad:slow-init
May 17, 2017
Merged

pubsub: start connections slowly#2055
pongad merged 2 commits intogoogleapis:masterfrom
pongad:slow-init

Conversation

@pongad
Copy link
Copy Markdown
Contributor

@pongad pongad commented May 12, 2017

Starting a new connection seems to add a task which blocks
a thread in our thread pool.
It does not block for long, but Subscriber starts many connections,
slamming the pool.
If the number of threads the pool is low, the pool is blocked for
a long time, causing strange delays and RPC failures.

This PR alleviates this problem by starting connections one at a time.

  • Each connection now make one successful call before declaring itself running.
  • The Subscriber waits for a connection to be in running state
    before starting another.

Together, these changes limit the number of blocking tasks
registered to the pool.

Since starting the Subscriber can now take a significant amount of time,
and doStart should return promptly,
a new thread is used to start up the connections.

cc @davidtorres @saturnism

Starting a new connection seems to add a task which blocks
a thread in our thread pool.
It does not block for long, but Subscriber starts many connections,
slamming the pool.
If the number of threads the pool is low, the pool is blocked for
a long time, causing strange delays and RPC failures.

This PR alleviates this problem by starting connections one at a time.
- Each connection now make one successful call before declaring itself running.
- The Subscriber waits for a connection to be in running state
  before starting another.

Together, these changes limit the number of blocking tasks
registered to the pool.

Since starting the Subscriber can now take a significant amount of time,
and `doStart` should return promptly,
a new thread is used to start up the connections.
@pongad pongad requested a review from garrettjonesgoogle May 12, 2017 05:45
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label May 12, 2017
@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 4c988ec on pongad:slow-init into ** on GoogleCloudPlatform:master**.

notifyFailed(t);
}
}
}).start();

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@pongad
Copy link
Copy Markdown
Contributor Author

pongad commented May 16, 2017

@garrettjonesgoogle @davidtorres PTAL

@coveralls
Copy link
Copy Markdown

Coverage Status

Changes Unknown when pulling 74a7aa1 on pongad:slow-init into ** on GoogleCloudPlatform:master**.

@garrettjonesgoogle
Copy link
Copy Markdown
Contributor

LGTM

@pongad pongad merged commit 5af4a46 into googleapis:master May 17, 2017
@pongad pongad deleted the slow-init branch May 17, 2017 10:36
pongad added a commit that referenced this pull request Jun 6, 2017
This PR undoes part of #2055.
Refreshing credentials blocks thread for a period of time.
Previously, each channel has its own credentials,
so starting many channels spams executor with many blocking tasks.
but the downside is we take a long time to fully start:
about 2 minutes on my machine.

Now, all connections share the same credentials,
so refreshing only happens once.
We can start quickly again.

Also rename setLeaseAlarmsExecutorProvider,
since the executor is now also used for polling.
suztomo pushed a commit to suztomo/google-cloud-java that referenced this pull request Mar 23, 2026
meltsufin pushed a commit that referenced this pull request Apr 29, 2026
…onfig to v1.8.0 (#2055)

* build(deps): update dependency com.google.cloud:google-cloud-shared-config to v1.8.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
meltsufin pushed a commit that referenced this pull request May 1, 2026
…onfig to v1.8.0 (#2055)

* build(deps): update dependency com.google.cloud:google-cloud-shared-config to v1.8.0

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
meltsufin pushed a commit that referenced this pull request May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants