Three simultaneous calls causes process spikes to 25% per callNginx: Limit number of simultaneous connections per IP to backenduwsgi : why two processes are loaded per each app?How to optimize uWSGI python app + nginx on Ubuntu?flask templates works in local env but return error 404 under nginxIs uWSGI's reload-on-rss per worker/process?Nginx websocket proxy uses three connections per socketsupervisor restart causes zombie uwsgi processNginx content caching causing Docker memory spikeFlask memory spike when processing big json requestKeep save authorized session on app with uswgi + flask + nginx
Slow query when having 'contains' and '=' together in where clause
Applications of mathematics in clinical setting
Can a business put whatever they want into a contract?
Inquiry answerer
What does the Free Recovery sign (UK) actually mean?
Microservices and Stored Procedures
Do household ovens ventilate heat to the outdoors?
MySQL - How to check for a value in all columns
Amiga 500 OCS/ECS vs Mega Drive VDP
All numbers in a 5x5 Minesweeper grid
Is it possible that the shadow of The Moon is a single dot during solar eclipse?
Persuading players to be less attached to a pre-session 0 character concept
Madrid to London w/ Expired 90/180 days stay as US citizen
Other than good shoes and a stick, what are some ways to preserve your knees on long hikes?
Can Brexit be undone in an emergency?
Very lazy puppy
Did slaves have slaves?
What's the benefit of prohibiting the use of techniques/language constructs that have not been taught?
adding downward arrow sign to lightning:help text
What exactly is a web font, and what does converting to one involve?
Which block header fields are miners able to change in an effort to avoid having to recalculate the Merkle Root?
Output Distinct Factor Cuboids
How far away from you does grass spread?
Is there a theorem in Real analysis similar to Cauchy's theorem in Complex analysis?
Three simultaneous calls causes process spikes to 25% per call
Nginx: Limit number of simultaneous connections per IP to backenduwsgi : why two processes are loaded per each app?How to optimize uWSGI python app + nginx on Ubuntu?flask templates works in local env but return error 404 under nginxIs uWSGI's reload-on-rss per worker/process?Nginx websocket proxy uses three connections per socketsupervisor restart causes zombie uwsgi processNginx content caching causing Docker memory spikeFlask memory spike when processing big json requestKeep save authorized session on app with uswgi + flask + nginx
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
to present my configuration I followed this tutorial until "Securing the application"
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04#step-4-%E2%80%94-configuring-uwsgi
So my .ini looks like this:
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
In flask i'm using SQLAlchemy with this configuration:
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 299
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 20
My api endpoints are like this with various themes, they receive parameters via get, process, and return a json
@app.route('/api/theme1/subtheme1')
@auth.login_required
def get_test1(): ...
@app.route('/api/theme1/subtheme2')
@auth.login_required
def get_test2(): ...
@app.route('/api/theme1/subtheme3')
@auth.login_required
def get_test3(): ...
Now my problem, when, for example I make 3 simultaneous calls (not other calls to the api) to those 3 endpoints procesor of the uwsgi process spikes to 25% per call.
Im using a tiny compute engine, just running this for now, the ram is for another tests. n1-highmem-2 (2 vCPUs, 13 GB memory)
I googled and search here and even tunning a little the configuration cannot reduce the processor usage, so I cannot improve the overall performance of the API.
Any idea of what can I be doing wrong? Why the spike in cpu usage?
Thank you!
nginx flask uwsgi
|
show 3 more comments
to present my configuration I followed this tutorial until "Securing the application"
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04#step-4-%E2%80%94-configuring-uwsgi
So my .ini looks like this:
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
In flask i'm using SQLAlchemy with this configuration:
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 299
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 20
My api endpoints are like this with various themes, they receive parameters via get, process, and return a json
@app.route('/api/theme1/subtheme1')
@auth.login_required
def get_test1(): ...
@app.route('/api/theme1/subtheme2')
@auth.login_required
def get_test2(): ...
@app.route('/api/theme1/subtheme3')
@auth.login_required
def get_test3(): ...
Now my problem, when, for example I make 3 simultaneous calls (not other calls to the api) to those 3 endpoints procesor of the uwsgi process spikes to 25% per call.
Im using a tiny compute engine, just running this for now, the ram is for another tests. n1-highmem-2 (2 vCPUs, 13 GB memory)
I googled and search here and even tunning a little the configuration cannot reduce the processor usage, so I cannot improve the overall performance of the API.
Any idea of what can I be doing wrong? Why the spike in cpu usage?
Thank you!
nginx flask uwsgi
I can think of 2 things. It could be an issue with whats in yourget_testd()functions or have you tried playing with the number of processes you are running?
– SudoKid
Mar 28 at 17:13
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09
|
show 3 more comments
to present my configuration I followed this tutorial until "Securing the application"
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04#step-4-%E2%80%94-configuring-uwsgi
So my .ini looks like this:
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
In flask i'm using SQLAlchemy with this configuration:
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 299
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 20
My api endpoints are like this with various themes, they receive parameters via get, process, and return a json
@app.route('/api/theme1/subtheme1')
@auth.login_required
def get_test1(): ...
@app.route('/api/theme1/subtheme2')
@auth.login_required
def get_test2(): ...
@app.route('/api/theme1/subtheme3')
@auth.login_required
def get_test3(): ...
Now my problem, when, for example I make 3 simultaneous calls (not other calls to the api) to those 3 endpoints procesor of the uwsgi process spikes to 25% per call.
Im using a tiny compute engine, just running this for now, the ram is for another tests. n1-highmem-2 (2 vCPUs, 13 GB memory)
I googled and search here and even tunning a little the configuration cannot reduce the processor usage, so I cannot improve the overall performance of the API.
Any idea of what can I be doing wrong? Why the spike in cpu usage?
Thank you!
nginx flask uwsgi
to present my configuration I followed this tutorial until "Securing the application"
https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uswgi-and-nginx-on-ubuntu-18-04#step-4-%E2%80%94-configuring-uwsgi
So my .ini looks like this:
[uwsgi]
module = wsgi:app
master = true
processes = 5
socket = myproject.sock
chmod-socket = 660
vacuum = true
die-on-term = true
In flask i'm using SQLAlchemy with this configuration:
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['SQLALCHEMY_POOL_RECYCLE'] = 299
app.config['SQLALCHEMY_POOL_TIMEOUT'] = 20
My api endpoints are like this with various themes, they receive parameters via get, process, and return a json
@app.route('/api/theme1/subtheme1')
@auth.login_required
def get_test1(): ...
@app.route('/api/theme1/subtheme2')
@auth.login_required
def get_test2(): ...
@app.route('/api/theme1/subtheme3')
@auth.login_required
def get_test3(): ...
Now my problem, when, for example I make 3 simultaneous calls (not other calls to the api) to those 3 endpoints procesor of the uwsgi process spikes to 25% per call.
Im using a tiny compute engine, just running this for now, the ram is for another tests. n1-highmem-2 (2 vCPUs, 13 GB memory)
I googled and search here and even tunning a little the configuration cannot reduce the processor usage, so I cannot improve the overall performance of the API.
Any idea of what can I be doing wrong? Why the spike in cpu usage?
Thank you!
nginx flask uwsgi
nginx flask uwsgi
edited Mar 31 at 2:15
Rob
12k8 gold badges33 silver badges54 bronze badges
12k8 gold badges33 silver badges54 bronze badges
asked Mar 28 at 13:21
AlejandroAlejandro
841 silver badge16 bronze badges
841 silver badge16 bronze badges
I can think of 2 things. It could be an issue with whats in yourget_testd()functions or have you tried playing with the number of processes you are running?
– SudoKid
Mar 28 at 17:13
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09
|
show 3 more comments
I can think of 2 things. It could be an issue with whats in yourget_testd()functions or have you tried playing with the number of processes you are running?
– SudoKid
Mar 28 at 17:13
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09
I can think of 2 things. It could be an issue with whats in your
get_testd() functions or have you tried playing with the number of processes you are running?– SudoKid
Mar 28 at 17:13
I can think of 2 things. It could be an issue with whats in your
get_testd() functions or have you tried playing with the number of processes you are running?– SudoKid
Mar 28 at 17:13
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398724%2fthree-simultaneous-calls-causes-process-spikes-to-25-per-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55398724%2fthree-simultaneous-calls-causes-process-spikes-to-25-per-call%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I can think of 2 things. It could be an issue with whats in your
get_testd()functions or have you tried playing with the number of processes you are running?– SudoKid
Mar 28 at 17:13
The local response is really fast (running flask standalone), it gets 3 fields from a table with 1 record, simple as that, then converts it to json and return data. It now uses 25% processor in each one of the three calls, if I lower it below 3 it will take longer I think, If I raise more than 5 it will have less processor to do the work...what logic should I use to adjust that value? Thanks!
– Alejandro
Mar 28 at 18:29
It’s just trial and error testing for things like this. Though you may want to check to make sure you don’t have debugging turned on. I have seen reports of this kind of issue around it.
– SudoKid
Mar 29 at 21:27
I'm about to try with gunicorn, but will very much like to learn what's happening here, thanks!
– Alejandro
Mar 31 at 3:03
Alejandro -- After looking at flask-httpauth source code, I think you should try removing @auth.login_required from each of those routes and try it again. If not, then I'm stumped. As a side note to the earlier comments, the general rule for number of processors is processors = (2 * CPU Cores) + 1.
– Brannon
Apr 5 at 21:09