Title: High cpu when using Gunicorn with multiprocess · Issue #568 · prometheus/client_python · GitHub
Open Graph Title: High cpu when using Gunicorn with multiprocess · Issue #568 · prometheus/client_python
X Title: High cpu when using Gunicorn with multiprocess · Issue #568 · prometheus/client_python
Description: I run flask app on Gunicorn 20.0.4 and Kubernetes. My python is v3.7.5. I have a problem with increasing CPU over a time. After investigating stack traces using py-spy I noticed that the issue is caused by prometheus metrics lib. It does...
Open Graph Description: I run flask app on Gunicorn 20.0.4 and Kubernetes. My python is v3.7.5. I have a problem with increasing CPU over a time. After investigating stack traces using py-spy I noticed that the issue is c...
X Description: I run flask app on Gunicorn 20.0.4 and Kubernetes. My python is v3.7.5. I have a problem with increasing CPU over a time. After investigating stack traces using py-spy I noticed that the issue is c...
Opengraph URL: https://github.com/prometheus/client_python/issues/568
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"High cpu when using Gunicorn with multiprocess","articleBody":"I run flask app on Gunicorn 20.0.4 and Kubernetes. My python is v3.7.5. I have a problem with increasing CPU over a time.\r\n\r\nAfter investigating stack traces using py-spy I noticed that the issue is caused by prometheus metrics lib.\r\nIt doesn't clean up metric files from old workers. Therefore over a time merge process take more and more CPU. \r\n\r\nAfter deleting following files the CPU usages dropped significantly:\r\n```\r\nll -lh\r\ntotal 7.0M\r\ndrwxr-xr-x 2 root root 4.0K Jul 24 06:13 ./\r\ndrwxrwxrwt 1 root root 4.0K Jul 19 14:14 ../\r\n-rw-r--r-- 1 root root 1.0M Jul 24 08:14 counter_106.db\r\n-rw-r--r-- 1 root root 1.0M Jul 23 18:41 counter_112.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 04:07 counter_118.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 04:54 counter_136.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 08:40 counter_142.db\r\n-rw-r--r-- 1 root root 1.0M Jul 20 16:44 counter_16.db\r\n-rw-r--r-- 1 root root 1.0M Jul 20 11:24 counter_17.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 01:40 counter_18.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 20:14 counter_40.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 17:17 counter_52.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 21:29 counter_58.db\r\n-rw-r--r-- 1 root root 1.0M Jul 23 07:19 counter_70.db\r\n-rw-r--r-- 1 root root 1.0M Jul 22 19:49 counter_82.db\r\n-rw-r--r-- 1 root root 1.0M Jul 22 18:59 counter_88.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 08:43 histogram_106.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 04:15 histogram_112.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 05:02 histogram_118.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 08:43 histogram_136.db\r\n-rw-r--r-- 1 root root 1.0M Jul 24 08:43 histogram_142.db\r\n-rw-r--r-- 1 root root 1.0M Jul 20 16:46 histogram_16.db\r\n-rw-r--r-- 1 root root 1.0M Jul 20 11:45 histogram_17.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 01:51 histogram_18.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 22:41 histogram_40.db\r\n-rw-r--r-- 1 root root 1.0M Jul 21 17:45 histogram_52.db\r\n-rw-r--r-- 1 root root 1.0M Jul 22 01:44 histogram_58.db\r\n-rw-r--r-- 1 root root 1.0M Jul 23 07:37 histogram_70.db\r\n-rw-r--r-- 1 root root 1.0M Jul 23 01:01 histogram_82.db\r\n-rw-r--r-- 1 root root 1.0M Jul 22 23:40 histogram_88.db\r\n```\r\n\r\n\r\nThe issue is related to https://github.com/prometheus/client_python/issues/275\r\n\r\nCan we avoid that somehow without periodically restating the k8s pod? Maybe multiprocess should use PID + UUID generated on worker rather than just PID for file names? So master could remove/merge files from dead workes?\r\n\r\n","author":{"url":"https://github.com/onzo-mateuszzakarczemny","@type":"Person","name":"onzo-mateuszzakarczemny"},"datePublished":"2020-07-24T09:46:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/568/client_python/issues/568"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:1f099e69-025d-ea92-b3d6-c830a4a810a9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A55A:96DD6:3637BC:46660B:6990699C |
| html-safe-nonce | bbd1d9b9b33960b6c56414a71d5d8f4174e62c4fc1f0ada3ecb4206686f67131 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTVBOjk2REQ2OjM2MzdCQzo0NjY2MEI6Njk5MDY5OUMiLCJ2aXNpdG9yX2lkIjoiNTI3NDY1NDE4NzAwNjc0OTA4NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | de123827a827aeb3ab1b1afdd81a1bd18f9af883309550c1ec8baf650daecdf5 |
| hovercard-subject-tag | issue:665053164 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/prometheus/client_python/568/issue_layout |
| twitter:image | https://opengraph.githubassets.com/46de37cdb379ac261d70a0425f32982036d04f0a47bffef4aebd5cfd9a98bf0b/prometheus/client_python/issues/568 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/46de37cdb379ac261d70a0425f32982036d04f0a47bffef4aebd5cfd9a98bf0b/prometheus/client_python/issues/568 |
| og:image:alt | I run flask app on Gunicorn 20.0.4 and Kubernetes. My python is v3.7.5. I have a problem with increasing CPU over a time. After investigating stack traces using py-spy I noticed that the issue is c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | onzo-mateuszzakarczemny |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/prometheus/client_python git https://github.com/prometheus/client_python.git |
| octolytics-dimension-user_id | 3380462 |
| octolytics-dimension-user_login | prometheus |
| octolytics-dimension-repository_id | 30618733 |
| octolytics-dimension-repository_nwo | prometheus/client_python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 30618733 |
| octolytics-dimension-repository_network_root_nwo | prometheus/client_python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3b33c5aedc9808f45bc5fcf0b1e4404cf749dac7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width