Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Scale gunicorn server to serve 1000 concurrent requests #195

Merged
merged 11 commits into from
Aug 11, 2022
38 changes: 28 additions & 10 deletions .github/workflows/conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,64 @@ jobs:
go-version: '1.16'

- name: Run HTTP conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
with:
version: 'v1.1.0'
version: 'v1.6.0'
functionType: 'http'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/main.py --target write_http --signature-type http'"

- name: Run event conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
with:
version: 'v1.1.0'
version: 'v1.6.0'
functionType: 'legacyevent'
useBuildpacks: false
validateMapping: true
cmd: "'functions-framework --source tests/conformance/main.py --target write_legacy_event --signature-type event'"

- name: Run CloudEvents conformance tests
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
with:
version: 'v1.1.0'
version: 'v1.6.0'
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: true
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event --signature-type cloudevent'"

- name: Run HTTP conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
with:
version: 'v1.1.0'
version: 'v1.6.0'
functionType: 'http'
useBuildpacks: false
validateMapping: false
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative'"

- name: Run CloudEvents conformance tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.1.0
uses: GoogleCloudPlatform/functions-framework-conformance/action@v1.6.0
with:
version: 'v1.1.0'
version: 'v1.6.0'
functionType: 'cloudevent'
useBuildpacks: false
validateMapping: true
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event_declarative'"

- name: Run HTTP concurrency tests declarative
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
with:
version: 'v1.6.0'
functionType: 'http'
useBuildpacks: false
validateConcurrency: true
cmd: "'functions-framework --source tests/conformance/main.py --target write_http_declarative_concurrent'"

- name: Run CloudEvents concurrency tests
kappratiksha marked this conversation as resolved.
Show resolved Hide resolved
uses: GoogleCloudPlatform/functions-framework-conformance/[email protected]
with:
version: 'v1.6.0'
functionType: 'cloudevent'
useBuildpacks: false
validateConcurrency: true
cmd: "'functions-framework --source tests/conformance/main.py --target write_cloud_event_declarative_concurrent'"
2 changes: 1 addition & 1 deletion src/functions_framework/_http/gunicorn.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, app, host, port, debug, **options):
self.options = {
"bind": "%s:%s" % (host, port),
"workers": 1,
"threads": 8,
"threads": 1024,
"timeout": 0,
"loglevel": "error",
"limit_request_line": 0,
Expand Down
13 changes: 13 additions & 0 deletions tests/conformance/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import time

from cloudevents.http import to_json

Expand Down Expand Up @@ -46,3 +47,15 @@ def write_http_declarative(request):
@functions_framework.cloud_event
def write_cloud_event_declarative(cloud_event):
_write_output(to_json(cloud_event).decode())


@functions_framework.http
def write_http_declarative_concurrent(request):
time.sleep(1)
return "OK", 200


@functions_framework.cloud_event
def write_cloud_event_declarative_concurrent(cloud_event):
time.sleep(1)
return "OK", 200
4 changes: 2 additions & 2 deletions tests/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ def test_gunicorn_application(debug):
assert gunicorn_app.options == {
"bind": "%s:%s" % (host, port),
"workers": 1,
"threads": 8,
"threads": 1024,
"timeout": 0,
"loglevel": "error",
"limit_request_line": 0,
}

assert gunicorn_app.cfg.bind == ["1.2.3.4:1234"]
assert gunicorn_app.cfg.workers == 1
assert gunicorn_app.cfg.threads == 8
assert gunicorn_app.cfg.threads == 1024
assert gunicorn_app.cfg.timeout == 0
assert gunicorn_app.load() == app

Expand Down