I created a simple app (flask + gunicorn) and uploaded it to Google App Engine to test how fast my request would be processed in a production environment. I was surprised to see a huge 0.7 to 1.2 second overhead introduced by using an http URL vs https one (cold request was even slower). Is this normal or am I doing something wrong here.
I also tested my app in Azure App Service; I could not get http to work, but https request (which I'm interested in) resulted in a similar lag.
main.py (server side)
from flask import Flask, requestapp = Flask(__name__)@app.route('/', methods=['POST'])def handle_request(): payload = request.json return payloadtest.py (client side)
import requestsimport timeclass Test: def __init__(self): self.url = "https://name.appspot.com" def send_request(self, **kwargs): response = requests.post(self.url, json=kwargs) return(response.text)if __name__ == '__main__': test = Test() text = "Hi" start = time.time() result = test.send_request(text=text) end = time.time() print(f'Retrieved {result} in {end - start}')Here are my config files for Google App Engine and Azure App Service.
Google (app.yaml):
runtime: python311instance_class: F1entrypoint: gunicorn -b :$PORT main:appAzure (startup.txt)
gunicorn -w 4 main:app