René's URL Explorer Experiment


Title: Issue · GitHub

Open Graph Title: Issue · googleapis/python-pubsub

X Title: Issue · googleapis/python-pubsub

Description: This library has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-pubsub - Issue · googleapis/python-pubsub

Open Graph Description: This library has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-pubsub - Issue · googleapis/python-pubsub

X Description: This library has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-pubsub - Issue · googleapis/python-pubsub

Opengraph URL: https://github.com/googleapis/python-pubsub

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pubsub: Consider a blocking publisher to prevent OOMing","articleBody":"Publishing medium-sized (32 kiB) messages in a loop causes the process's memory usage to quickly run out. I set a 2 GiB memory limit, and the process runs out of memory after publishing about 20000 messages. I believe there are two issues:\r\n\r\n1. There is no limit to the number of queued bytes in the process.\r\n2. The client library keeps 3 copies of the messages and retains them until the batch \"monitor\" thread finishes.\r\n\r\n\r\nAs far as I can see, there no good way to use the current client library to publish large batches of messages without HUGE memory consumption. I believe this can be fixed in two ways:\r\n\r\n#### Reduce memory of the current library:\r\n\r\n1. Release messages when the batch is done: In `thread.Batch._commit`, set `self._messages` to `None` after it is published. This *seems* to make memory consumption better, but I didn't test it super carefully.\r\n\r\n2. Eliminate an extra copy: Change thread.Batch to build a PubsubRequest, and pass *that* into the gapic.PublisherClient, rather than a list of messages that then need to be copied. This reduces one copy of messages, which seems to make memory consumption better (and possibly make things faster? again not tested carefully)\r\n\r\n#### Back Pressure\r\n\r\nChange the publisher to keep a queue of batches, and block after there are more than N in flight at once.\r\n\r\nI implemented a client that takes the blocking queue approach. It can publish this workload without ever exceeding 300 MiB of memory. Only 3 in-flight batches were necessary to have the process be CPU bound when running in Google Cloud, so I don't think the queue doesn't even need to be too large.\r\n\r\n\r\n\r\n#### Environment details\r\n\r\n*OS*: Linux, ContainerOS (GKE), Container is Debian9 (using distroless)\r\n*Python*: 3.5.3\r\n*API*: google-cloud-python 0.41.0\r\n\r\n\r\n\r\n#### Steps to reproduce\r\n\r\n1. Package the following program in a Docker container.\r\n2. Run it in Kubernetes with a memory limit of 2 GiB\r\n3. Watch it blow up when you run it.\r\n\r\n\r\n#### Code example\r\n\r\n```python\r\n#!/usr/bin/env python3\r\n'''\r\nCreate the topic and a subscription:\r\n\r\ngcloud pubsub topics create deleteme_publish_memleak_test\r\ngcloud pubsub subscriptions create deleteme_memleak_subscription --topic=deleteme_publish_memleak_test\r\n'''\r\n\r\nfrom google.cloud import pubsub_v1\r\nimport argparse\r\nimport google.auth\r\nimport logging\r\nimport time\r\n\r\n\r\ndef main():\r\n    parser = argparse.ArgumentParser(description='mass publish to pub/sub')\r\n    parser.add_argument('--topic',\r\n                        default='deleteme_publish_memleak_test',\r\n                        help='topic to publish to')\r\n    parser.add_argument('--messages',\r\n                        type=int,\r\n                        default=200000,\r\n                        help='number of messages to publish')\r\n    parser.add_argument('--bytes_per_message',\r\n                        type=int,\r\n                        default=32 * 1024,\r\n                        help='bytes per message to publish')\r\n    parser.add_argument('--log_every_n', type=int, default=2000, help='log every N messages')\r\n    args = parser.parse_args()\r\n\r\n    credentials, project_id = google.auth.default()\r\n    publish_client = pubsub_v1.PublisherClient(credentials=credentials)\r\n    topic_path = publish_client.topic_path(project_id, args.topic)\r\n\r\n    logging.basicConfig(\r\n        level=logging.DEBUG,\r\n        format='%(asctime)s %(levelname)s %(name)s: %(message)s',\r\n    )\r\n    logging.info('publishing %d messages to topic %s; %d bytes per message; %.1f total MiB',\r\n                 args.messages, topic_path, args.bytes_per_message,\r\n                 (args.messages * args.bytes_per_message) / 1024. / 1024.)\r\n\r\n    start = time.time()\r\n    for i in range(args.messages):\r\n        message = (i % 256).to_bytes(1, byteorder='little') * args.bytes_per_message\r\n        publish_client.publish(topic_path, message)\r\n        if i % args.log_every_n == 0:\r\n            logging.info('published %d messages', i)\r\n\r\n    end = time.time()\r\n    logging.info('done publishing in %f s', end - start)\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n```\r\n","author":{"url":"https://github.com/evanj","@type":"Person","name":"evanj"},"datePublished":"2019-05-16T21:39:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/16/python-pubsub/issues/16"}

route-pattern/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:2267481b-f38d-adbe-9dd4-4a693553deb0
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8E74:352AFE:E89FD5:1387FB2:6A4D4DF4
html-safe-noncea46cfee099976cc4789ce6abb02acd603bd20cd85c6e903cc1da571e2f9d6f6a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTc0OjM1MkFGRTpFODlGRDU6MTM4N0ZCMjo2QTRENERGNCIsInZpc2l0b3JfaWQiOiI1OTU2OTA1ODQ2NDUzMzkwODM3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac901ee41b564fa9114a77ed32ed6405a767371de5c39d3ab29097137b65c16be4
hovercard-subject-tagrepository:226992581
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/googleapis/python-pubsub/issues/16
twitter:imagehttps://opengraph.githubassets.com/3cc54f98105166e25e3650050536d50853f8444ec91dab7fd33ced5df2899749/googleapis/python-pubsub
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3cc54f98105166e25e3650050536d50853f8444ec91dab7fd33ced5df2899749/googleapis/python-pubsub
og:image:altThis library has moved to https://github.com/googleapis/google-cloud-python/tree/main/packages/google-cloud-pubsub - Issue · googleapis/python-pubsub
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6
turbo-cache-controlno-cache
go-importgithub.com/googleapis/python-pubsub git https://github.com/googleapis/python-pubsub.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992581
octolytics-dimension-repository_nwogoogleapis/python-pubsub
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992581
octolytics-dimension-repository_network_root_nwogoogleapis/python-pubsub
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release56fc8347865a14e2ec811533d68f929cf4e0ec19
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-pubsub/issues/16#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-pubsub%2Fissues%2F16
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-pubsub%2Fissues%2F16
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=googleapis%2Fpython-pubsub
Reloadhttps://github.com/googleapis/python-pubsub/issues/16
Reloadhttps://github.com/googleapis/python-pubsub/issues/16
Reloadhttps://github.com/googleapis/python-pubsub/issues/16
Please reload this pagehttps://github.com/googleapis/python-pubsub/issues/16
googleapis https://github.com/googleapis
python-pubsubhttps://github.com/googleapis/python-pubsub
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-pubsub
Fork 214 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-pubsub
Star 430 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-pubsub
Code https://github.com/googleapis/python-pubsub
Issues 0 https://github.com/googleapis/python-pubsub/issues
Pull requests 0 https://github.com/googleapis/python-pubsub/pulls
Actions https://github.com/googleapis/python-pubsub/actions
Projects https://github.com/googleapis/python-pubsub/projects
Security and quality 0 https://github.com/googleapis/python-pubsub/security
Insights https://github.com/googleapis/python-pubsub/pulse
Code https://github.com/googleapis/python-pubsub
Issues https://github.com/googleapis/python-pubsub/issues
Pull requests https://github.com/googleapis/python-pubsub/pulls
Actions https://github.com/googleapis/python-pubsub/actions
Projects https://github.com/googleapis/python-pubsub/projects
Security and quality https://github.com/googleapis/python-pubsub/security
Insights https://github.com/googleapis/python-pubsub/pulse
#96https://github.com/googleapis/python-pubsub/pull/96
Pubsub: Consider a blocking publisher to prevent OOMinghttps://github.com/googleapis/python-pubsub/issues/16#top
#96https://github.com/googleapis/python-pubsub/pull/96
https://github.com/plamut
api: pubsubIssues related to the googleapis/python-pubsub API.https://github.com/googleapis/python-pubsub/issues?q=state%3Aopen%20label%3A%22api%3A%20pubsub%22
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.https://github.com/googleapis/python-pubsub/issues?q=state%3Aopen%20label%3A%22type%3A%20feature%20request%22
https://github.com/evanj
evanjhttps://github.com/evanj
on May 16, 2019https://github.com/googleapis/python-pubsub/issues/16#issue-558134142
plamuthttps://github.com/plamut
api: pubsubIssues related to the googleapis/python-pubsub API.https://github.com/googleapis/python-pubsub/issues?q=state%3Aopen%20label%3A%22api%3A%20pubsub%22
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.https://github.com/googleapis/python-pubsub/issues?q=state%3Aopen%20label%3A%22type%3A%20feature%20request%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.