Skip to content

Commit 7f12f61

Browse files
authored
Adding support for concurrent HTTP requests with asyncio (#5)
* First swing at async httpx * Cloudbuild configuration file for pull requests * Adding simple perf stats * Fixing tag-based traffic routing * Initial optimization for HTTPX session reuse * Adding support for gzipped responses * Better handling where the User-Agent header is not set * Cleanup and better comments for launch * Better error handling * Dealing with no inventory results * Fine tuning traffic routing * Updating perf logging
1 parent 7dc5e7b commit 7f12f61

File tree

6 files changed

+402
-134
lines changed

6 files changed

+402
-134
lines changed

cloudbuild-pr.yaml

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Build Configuration to be used when a PR is opened or updated.
2+
steps:
3+
# Build the EV Finder API container image
4+
- name: "gcr.io/cloud-builders/docker"
5+
args:
6+
[
7+
"build",
8+
"-t",
9+
"us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}",
10+
".",
11+
]
12+
13+
# Push to Artifact Registry
14+
- name: "gcr.io/cloud-builders/docker"
15+
args:
16+
[
17+
"push",
18+
"us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}",
19+
]
20+
id: "docker push"
21+
22+
# Build and Deploy the API to Cloud Run
23+
- name: google/cloud-sdk
24+
args:
25+
[
26+
"gcloud",
27+
"run",
28+
"deploy",
29+
"api",
30+
"--image",
31+
"us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}",
32+
"--set-env-vars",
33+
"VERSION=${TAG_NAME}",
34+
"--region",
35+
"us-central1",
36+
"--platform",
37+
"managed",
38+
"--execution-environment",
39+
"gen1",
40+
"--cpu-boost",
41+
"--memory",
42+
"512Mi",
43+
"--use-http2",
44+
"--allow-unauthenticated",
45+
"--tag",
46+
"canary",
47+
"--no-traffic",
48+
]
49+
id: "deploy main api"
50+
waitFor:
51+
- "docker push"
52+
53+
# Build and deploy the Ford API
54+
- name: google/cloud-sdk
55+
args:
56+
[
57+
"gcloud",
58+
"run",
59+
"deploy",
60+
"ford-api",
61+
"--image",
62+
"us-central1-docker.pkg.dev/${PROJECT_ID}/evfinder-api/evfinder-api:${TAG_NAME}",
63+
"--set-env-vars",
64+
"VERSION=${TAG_NAME}",
65+
"--region",
66+
"us-central1",
67+
"--platform",
68+
"managed",
69+
"--execution-environment",
70+
"gen1",
71+
"--cpu-boost",
72+
"--memory",
73+
"512Mi",
74+
"--use-http2",
75+
"--allow-unauthenticated",
76+
"--tag",
77+
"canary",
78+
"--no-traffic",
79+
]
80+
id: "deploy ford api"
81+
waitFor:
82+
- "docker push"
83+
84+
# Swing traffic over to the newly deploy API
85+
- name: google/cloud-sdk
86+
args:
87+
[
88+
"gcloud",
89+
"run",
90+
"services",
91+
"update-traffic",
92+
"api",
93+
"--to-tags",
94+
"canary=50",
95+
"--region",
96+
"us-central1",
97+
]
98+
waitFor:
99+
- "deploy main api"
100+
101+
# Swing traffic over to the newly deploy Ford API
102+
- name: google/cloud-sdk
103+
args:
104+
[
105+
"gcloud",
106+
"run",
107+
"services",
108+
"update-traffic",
109+
"ford-api",
110+
"--to-tags",
111+
"canary=50",
112+
"--region",
113+
"us-central1",
114+
]
115+
waitFor:
116+
- "deploy ford api"
117+
118+
images:
119+
- "us-central1-docker.pkg.dev/evfinder/evfinder-api/evfinder-api:${TAG_NAME}"
120+
121+
options:
122+
logging: CLOUD_LOGGING_ONLY

cloudbuild.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ steps:
4141
"512Mi",
4242
"--use-http2",
4343
"--allow-unauthenticated",
44+
"--tag",
45+
"latest",
46+
"--no-traffic",
4447
]
4548
id: "deploy main api"
4649
waitFor:
@@ -69,6 +72,9 @@ steps:
6972
"512Mi",
7073
"--use-http2",
7174
"--allow-unauthenticated",
75+
"--tag",
76+
"latest",
77+
"--no-traffic",
7278
]
7379
id: "deploy ford api"
7480
waitFor:
@@ -83,7 +89,8 @@ steps:
8389
"services",
8490
"update-traffic",
8591
"api",
86-
"--to-latest",
92+
"--to-tags",
93+
"latest=100",
8794
"--region",
8895
"us-central1",
8996
]
@@ -99,7 +106,8 @@ steps:
99106
"services",
100107
"update-traffic",
101108
"ford-api",
102-
"--to-latest",
109+
"--to-tags",
110+
"latest=100",
103111
"--region",
104112
"us-central1",
105113
]

0 commit comments

Comments
 (0)