0

I have a Flask service made with Swagger Editor and Swagger Codegen (python flask). The code generated uses Connexion and Flask to serve the application.

This service has an endpoint that, on its own, answers the request in just 300ms (when tested both with a unit test and with curl).

def endpoint():
    # Endpoint implementation
    ...

I also have a wrapper that makes a simple validation and takes just 200ms (when tested with a unit test).

def validation_wrapper(param1, param2):
    def validation_wrapper_outer(func):
        @wraps(func)
        def validation_wrapper_inner(*args, **kwargs):
            # Do some validations
            ...
            return func(*args, **kwargs)
        return validation_wrapper_inner
    return validation_wrapper_outer

But when I combine the two, the response time skyrockets up to 2500ms (unit test and curl also). I need to keep it under 1000ms.

@validation_wrapper(param1=1, param2=2)
def endpoint():
    # Endpoint implementation
    ...

What could be causing this problem? Is there another way I can implement this functionality but improving the response times?

Samuel O.D.
  • 346
  • 2
  • 13

1 Answers1

0

I've deployed the service in a Docker container in Docker desktop, and the response times are much closer to the expected ones. It seems like a problem related to local deployment (in Windows in my case). As we use Docker for our environments, this solves the issue.

Samuel O.D.
  • 346
  • 2
  • 13