Simpler.Grants.gov Public Wiki
Grants.govSimpler.Grants.govGitHubDiscourse
  • 👋Welcome
  • GET INVOLVED
    • Why open source?
    • How to contribute code
    • How to file issues
      • Report a bug
      • Request a feature
      • Report a security vulnerability
    • Community guidelines
      • Code of Conduct
      • Reporting and removing content
      • Incident response protocol
    • Community events
      • Fall 2024 Coding Challenge
        • Event Submissions & Winners
      • Spring 2025 Collaborative Coding Challenge
        • Event Submissions & Winners
    • Communication channels
  • Product
    • Roadmap
    • Deliverables
      • 🏁Static site soft launch
      • 🏁Static site public launch
      • 🏁GET Opportunities
      • 🏁Open source onboarding
      • 🏁Co-Design Group planning
    • Decisions
      • ADR Template
      • ADRs
        • Dedicated Forum for Simpler.Grants.gov Community
        • Recording Architecture Decisions
        • Task Runner for the CI / CD Pipeline
        • API Language
        • Use Figma for design prototyping
        • ADR: Chat
        • DB Choices
        • API Framework and Libraries
        • Back-end Code Quality Tools
        • Front-end Language
        • Communications Tooling: Wiki Platform
        • Use Mural for design diagrams and whiteboarding
        • Ticket Tracking
        • Front-end Framework
        • Front-end Code Quality Tools
        • Front-end Testing & Coverage
        • Backend API Type
        • Front-end Testing & Coverage
        • Deployment Strategy
        • Use U.S. Web Design System for components and utility classes
        • FE server rendering
        • Use NPM over Yarn Architectural Decision Records
        • U.S. Web Design System in React
        • Communications Tooling: Video Conferencing
        • Back-end Production Server
        • Communications Tooling: Analytics Platform
        • Commit and Branch Conventions and Release Workflow
        • Cloud Platform to Host the Project
        • Infrastructure as Code Tool
        • Data Replication Strategy & Tool
        • HHS Communications Site
        • Communications Tooling: Email Marketing
        • Communications Tooling: Listserv
        • Use Ethnio for design research
        • Uptime Monitoring
        • Database Migrations
        • 30k ft deliverable reporting strategy
        • Public measurement dashboard architecture
        • Method and technology for "Contact Us" CTA
        • E2E / Integration Testing Framework
        • Logging and Monitoring Platform
        • Dashboard Data Storage
        • Dashboard Data Tool
        • Search Engine
        • Document Storage
        • Document Sharing
        • Internal Wiki ADR
        • Shared Team Calendar Platform
        • Cross-Program Team Health Survey Tool
        • Adding Slack Users to SimplerGrants Slack Workspace
        • Repo organization
        • Internal knowledge management
        • Migrate Existing API Consumers
      • Infra
        • Use markdown architectural decision records
        • CI/CD interface
        • Use custom implementation of GitHub OIDC
        • Manage ECR in prod account module
        • Separate terraform backend configs into separate config files
        • Database module design
        • Provision database users with serverless function
        • Database migration architecture
        • Consolidate infra config from tfvars files into config module
        • Environment use cases
        • Production networking long term state
    • Analytics
      • Open source community metrics
      • API metrics
  • DESIGN & RESEARCH
    • Brand guidelines
      • Logo
      • Colors
      • Grid and composition
      • Typography
      • Iconography
      • Photos and illustrations
    • Content guidelines
      • Voice and tone
    • User research
      • Grants.gov archetypes
  • REFERENCES
    • Glossary
  • How to edit the wiki
Powered by GitBook
On this page
  • Context and Problem Statement
  • Decision Drivers
  • Options Considered
  • Production Server
  • Implementation
  • Decision Outcome
  • Production Server
  • Implementation
  • Pros and Cons of the Options
  • Production Server
  • Implementation

Was this helpful?

Edit on GitHub
  1. Product
  2. Decisions
  3. ADRs

Back-end Production Server

PreviousCommunications Tooling: Video ConferencingNextCommunications Tooling: Analytics Platform

Last updated 28 days ago

Was this helpful?

  • Status: Accepted

  • Last Modified: 2023-07-2i

  • Related Issue:

  • Deciders: Daphne, Sammy, Billy, Lucas

  • Tags: ADR

Context and Problem Statement

The Flask development server is not meant for production use and only intended for local development. It is not secure, stable, efficient, or scaled for a production environment. In addition to choosing a production server, this ADR will specify a high level implementation option.

Decision Drivers

  • Scalable: The chosen solution should be configurable to scale and a multi-worker, multi-threaded production-ready, WSGI wrapper.

  • Ease of use: The production server should be relatively simple to set up and start.

  • Well-maintained: We have a preference towards a production server that is widely adopted and have active maintainers.

Options Considered

Production Server

  • Gunicorn

  • Waitress

Implementation

  1. API entrypoint responsible for conditional logic determining dev vs prod environment and starting corresponding server

  2. Dockerfile executable command for the dev server is overridden in docker-compose.yml, API by default starts prod server

Decision Outcome

Production Server

Chosen option: Gunicorn, because it is the industry standard, well-supported and documented.

Implementation

Chosen option: #3 Dockerfile executable command for the dev server is overridden in docker-compose.yml, API by default starts prod server. This is because it makes the most sense in our current development ecosystem and abstracts away the concept of environment in the API layer.

Pros and Cons of the Options

Production Server

  • Pros

    • Widely used, industry standard Python server

    • Excellent ability to manage workers

    • Simple and light on resources, written in C

    • Highly compatible with most Python tooling

  • Cons

    • Does not run on Windows without WSL 🧐

  • Pros

    • Simple, lightweight

    • Can run on Windows as well as UNIX systems

    • No dependencies that aren't part of the standard Python library

    • Purely Python

  • Cons

    • Runs on CPython and has "very acceptable performance"

Implementation

#1 API entrypoint responsible for conditional logic determining dev vs prod environment and starting corresponding server

  • Pros

    • This is how the Flask app is already configured (small lift to modify)

  • Cons

    • Poor separation of concerns: apps remaining environment agnostic keeps them much simpler overall

    • Can lead to confusing environment conditional logic

  • Pros

    • Terraform handles our infrastructure and deployments, therefore conceptually makes sense to define Docker run commands in the task definition

  • Cons

    • Ignores docker-compose.yml for local development as a tool we have at our disposal

    • Obscures prod server run command outside app ecosystem in IaC

    • Implementation could potentially use separate app entry points for dev and prod

#3 Dockerfile executable command for the dev server is overridden in docker-compose.yml, API by default starts prod server

  • Pros

    • Local development is done via docker-compose.yml config, so it makes a ton of conceptual sense to pass a local Docker run command here

  • Cons

    • Implementation could potentially use separate app entry points for dev and prod

Dockerfile executable command for the prod server is overridden in the IaC , API by default starts dev server

Note: Gunicorn can be set up either using their unique or in our code using separate app entry points for dev and prod. We want to make sure we are scaling the appropriate number of workers based on CPU.

#2 Dockerfile executable command for the prod server is overridden in the IaC , API by default starts dev server

#245
task definition
configuration file
Gunicorn
Waitress
task definition