-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore(docs): Changed tutorial to how-to. Updated spread test.
- Loading branch information
1 parent
5000827
commit 5d7739e
Showing
9 changed files
with
62 additions
and
466 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Flask | ||
gevent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
====================================================== | ||
How to write a Kubernetes charm for an Async Flask app | ||
====================================================== | ||
|
||
In this how to we will configure 12 Factor Flask application | ||
to use asynchronous Gunicorn workers to be able to serve | ||
to multiple users easily. | ||
|
||
Make the rock async | ||
=================== | ||
|
||
Before packing the rock make sure to put the following in ``requirements.txt`` | ||
file: | ||
|
||
.. literalinclude:: code/flask-async/requirements.txt | ||
|
||
Configure the async application | ||
=============================== | ||
|
||
Now let's enable async Gunicorn workers using a configuration option. We will | ||
expect this configuration option to be available in the Flask app configuration | ||
under the keyword ``webserver-worker-class``. Verify that the new configuration | ||
has been added using | ||
``juju config flask-async-app | grep -A 6 webserver-worker-class:`` which should | ||
show the configuration option. | ||
|
||
.. note:: | ||
|
||
The ``grep`` command extracts a portion of the configuration to make | ||
it easier to check whether the configuration option has been added. | ||
|
||
The worker class can be changed using Juju: | ||
|
||
.. literalinclude:: code/flask-async/task.yaml | ||
:language: bash | ||
:start-after: [docs:config-async] | ||
:end-before: [docs:config-async-end] | ||
:dedent: 2 | ||
|
||
Now you can run | ||
``curl --parallel --parallel-immediate --resolve flask-async-app:80:127.0.0.1 \ | ||
http://flask-async-app/io http://flask-async-app/io http://flask-async-app/io \ | ||
http://flask-async-app/io http://flask-async-app/io`` | ||
in they will all return at the same time. | ||
|
||
.. note:: | ||
|
||
It might take a short time for the configuration to take effect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ How-To | |
charm-to-poetry | ||
charm-to-python | ||
shared-cache | ||
flask-async |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.