Skip to content

refactor: benchmark #1

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

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*.pyd
*.swp
*.log

.env
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM python:3.11-slim as base

RUN apt update && apt install -y git && rm -rf /var/lib/apt/lists/*

RUN pip install pip --upgrade

WORKDIR /app

CMD ["uvicorn", "octopus.asgi:application", "--host", "0.0.0.0", "--port", "8000"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need different web servers for sync/async: gunicorn and uvicorn


# graphene-django main version
FROM base as sync

COPY project/sync /app/

RUN pip install -r requirements.txt

# graphene-django PR version
FROM base as async

COPY project/async /app/

RUN pip install -r requirements.txt
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
up:
docker compose up -d --build
.PHONY: up

down:
docker compose down
.PHONY: down

sync_benchmark_main:
cd tests && ./run-main-sync.sh
.PHONY: sync_benchmark_main

sync_benchmark_PR:
cd tests && ./run-PR-sync.sh
.PHONY: sync_benchmark_PR

async_benchmark_PR:
cd tests && ./run-PR-async.sh
.PHONY: async_benchmark_PR
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: "3.8"

services:
postgres:
image: postgres:16.1
container_name: graphene-django-benchmark-postgres
environment:
POSTGRES_DB: benchmark
POSTGRES_USER: user
POSTGRES_PASSWORD: password
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d benchmark -U user"]
interval: 1s
timeout: 1s
retries: 10

population:
build:
context: .
target: sync
container_name: graphene-django-benchmark-population
command: bash -c "python manage.py migrate && python manage.py generate"
depends_on:
postgres:
condition: service_healthy

service-graphene-django-sync:
build:
context: .
target: sync
container_name: graphene-django-benchmark-service-graphene-django-sync
depends_on:
population:
condition: service_completed_successfully
ports:
- "8000:8000"

service-graphene-django-async:
build:
context: .
target: async
container_name: graphene-django-benchmark-service-graphene-django-async
depends_on:
population:
condition: service_completed_successfully
ports:
- "8001:8000"
16 changes: 0 additions & 16 deletions project/Pipfile

This file was deleted.

165 changes: 0 additions & 165 deletions project/Pipfile.lock

This file was deleted.

3 changes: 0 additions & 3 deletions project/api/admin.py

This file was deleted.

3 changes: 0 additions & 3 deletions project/api/views.py

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def resolve_octopuses(self, info, **kwargs):
.prefetch_related('seafood')
.all()
)
async for i in qs[:10]:
async for i in qs[:500]:
yield i

async def resolve_octopus(self, info, id):
Expand Down
10 changes: 10 additions & 0 deletions project/async/api/schema_sync/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import graphene

from api.schema_sync.queries import OctopusQuery


class Query(OctopusQuery):
pass


schema_sync = graphene.Schema(query=Query)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading