uvicorn-gunicorn-fastapi-docker | Docker image with Uvicorn | REST library

 by   tiangolo Python Version: 0.7.0 License: MIT

kandi X-RAY | uvicorn-gunicorn-fastapi-docker Summary

kandi X-RAY | uvicorn-gunicorn-fastapi-docker Summary

uvicorn-gunicorn-fastapi-docker is a Python library typically used in Web Services, REST, Fastapi, Docker, Swagger applications. uvicorn-gunicorn-fastapi-docker has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. However uvicorn-gunicorn-fastapi-docker build file is not available. You can download it from GitHub.

FastAPI has shown to be a Python web framework with one of the best performances, as measured by third-party benchmarks, thanks to being based on and powered by Starlette. The achievable performance is on par with (and in many cases superior to) Go and Node.js frameworks. This image has an auto-tuning mechanism included to start a number of worker processes based on the available CPU cores. That way you can just add your code and get high performance automatically, which is useful in simple deployments.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              uvicorn-gunicorn-fastapi-docker has a medium active ecosystem.
              It has 2222 star(s) with 301 fork(s). There are 24 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 31 open issues and 79 have been closed. On average issues are closed in 284 days. There are 6 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of uvicorn-gunicorn-fastapi-docker is 0.7.0

            kandi-Quality Quality

              uvicorn-gunicorn-fastapi-docker has 0 bugs and 0 code smells.

            kandi-Security Security

              uvicorn-gunicorn-fastapi-docker has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              uvicorn-gunicorn-fastapi-docker code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              uvicorn-gunicorn-fastapi-docker is licensed under the MIT License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              uvicorn-gunicorn-fastapi-docker releases are available to install and integrate.
              uvicorn-gunicorn-fastapi-docker has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions, examples and code snippets are available.
              uvicorn-gunicorn-fastapi-docker saves you 55 person hours of effort in developing the same functionality from scratch.
              It has 144 lines of code, 12 functions and 6 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed uvicorn-gunicorn-fastapi-docker and discovered the below as its top functions. This is intended to give you an instant insight into uvicorn-gunicorn-fastapi-docker implemented functionality, and help decide if they suit your requirements.
            • Print the version envs .
            • Main entry point .
            • Run a script .
            • Read root message .
            Get all kandi verified functions for this library.

            uvicorn-gunicorn-fastapi-docker Key Features

            No Key Features are available at this moment for uvicorn-gunicorn-fastapi-docker.

            uvicorn-gunicorn-fastapi-docker Examples and Code Snippets

            Docker 启动
            Pythondot img1Lines of Code : 4dot img1no licencesLicense : No License
            copy iconCopy
            docker build -t mallapp .
            
            
            docker run -d --name mycontainer -p 8030:8030 mallapp
            
            docker run -d --name mycontainer -p 80:80 mallapp
              

            Community Discussions

            QUESTION

            Running FastAPI on Google Cloud Run (Docker Image)
            Asked 2021-Oct-13 at 18:54

            I'm looking to build a Docker image to run FastAPI on Google Cloud Run. FastAPI uses Uvicorn as an ASGI server and Uvicorn recommend using Gunicorn with the Uvicorn worker class for production deployments. FastAPI themselves also have some excellent documentation on using Gunicorn with Uvicorn. I even see that FastAPI provide an official image combining the two ( uvicorn-gunicorn-fastapi-docker) but this comes with a warning:

            You are probably using Kubernetes or similar tools. In that case, you probably don't need this image (or any other similar base image). You are probably better off building a Docker image from scratch

            This warning basically explains that replication would be handled at cluster-level and doesn't need to be handled at process-level. This makes sense. I am however not quite sure if Cloud Run falls into this category? Essentially it is an abstracted and managed Knative service which therefore runs on Kubernetes.

            My question is, should I be installing Gunicorn along with Uvicorn in my Dockerfile and handling replication at process-level? Along the lines of:

            ...

            ANSWER

            Answered 2021-Oct-13 at 18:54

            A. Let's go the big scale first.

            At the time of writing Cloud Run instances can be set to a maximum of 1000 concurrency requests. And CPUs can be set to 4 vCPUs.

            Going back to basics a bit. Cloud Run will span many instances, each will work individually, and each could handle the maximum allowed concurrency, so each could handle 1000 requests. If you set multiple CPUs you need to handle multi processes.

            When we talk about so large number we need to be cautious. If your container is big enough in CPU/Memory terms to handle this traffic, you may want to use a process manager (gunicorn) to start several Uvicorn threads (workers), as your referenced images do. So you can use the docker container.

            B. Being on small scale.

            On the other hand if you set 1 vCPU and be single threaded, you don't need gunicorn for process manager. You still can have concurrency enabled but not on the top level, maybe at the lower level, that fits your 1 vCPU model, something like 80 requests for concurrency. In this situation you will have on large traffic, many instances started by Cloud Run, and you rely at Cloud Run to spawn as many instances as needed, which does really nice. It's like a Kubernetes on top of your simple container.

            I would suggest start with single process, build a container that doesn't use the referenced container, and only swap B to version A, when you know there are benefits(costs wise) to have larger instances.

            Source https://stackoverflow.com/questions/69558683

            QUESTION

            FastAPI gunicon uvicorn access_log format customization
            Asked 2020-Nov-12 at 16:23

            We are using the https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker FastAPI and were able to customize our logging with a gunicorn logging file.

            However, we are not able to change the details of the %(message)s attribute as defined in the documentation access log - https://docs.gunicorn.org/en/stable/settings.html#accesslog.

            We receive an error postet below, that the keys are unknown. A similar question has been asked before and received many upvotes. gunicorn log-config access_log_format

            What are we doing wrong?

            ...

            ANSWER

            Answered 2020-Nov-12 at 16:23

            Our solution was a customer logger written in python that is referenced in a logging.conf file

            logging.conf

            Source https://stackoverflow.com/questions/62894952

            QUESTION

            Correct nginx.conf loadbalancing to uvicorn FastAPI with docker-compose
            Asked 2020-Apr-09 at 02:23

            I want to use nginx as load balancer to my FastAPI replicas but i cannot get it to work. I read that uvicorn can also do it, but nginx would handle load balancing nicely. forum post.

            I get an error

            ...

            ANSWER

            Answered 2020-Apr-09 at 02:23

            As your nginx.conf file :

            server inconnect:5001; should be server inconnect1:5001;

            And in docker compose file should use link from nginx container to inconnect1 application. (remove network on nginx container)

            Source https://stackoverflow.com/questions/61112808

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install uvicorn-gunicorn-fastapi-docker

            Now you have an optimized FastAPI server in a Docker container. Auto-tuned for your current server (and number of CPU cores).
            Go to your project directory.
            Create a Dockerfile with:
            Create an app directory and enter in it.
            Create a main.py file with:
            You should now have a directory structure like:
            Go to the project directory (in where your Dockerfile is, containing your app directory).
            Build your FastAPI image:
            Run a container based on your image:

            Support

            python3.9, latest (Dockerfile)python3.8, (Dockerfile)python3.7, (Dockerfile)python3.6 (Dockerfile)python3.9-slim (Dockerfile)python3.8-slim (Dockerfile)
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/tiangolo/uvicorn-gunicorn-fastapi-docker.git

          • CLI

            gh repo clone tiangolo/uvicorn-gunicorn-fastapi-docker

          • sshUrl

            git@github.com:tiangolo/uvicorn-gunicorn-fastapi-docker.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link