Deploy and scale a Symfony ChatGPT app with Upsun

Deploy and scale a Symfony ChatGPT app with Upsun

May 27, 2024· Guillaume Moigneu
Guillaume Moigneu

Deploying an app for the first time is always daunting. It does not need to be. Setup a quick ChatGPT client based on a Symfony REST API and a React frontend with Guillaume MOIGNEU. This app will be deployed to Upsun where we will analyze some performance bottlenecks and scale the infrastructure appropriately based on these findings.


Enterprise Symfony for the future: Platform.sh is the official Symfony Cloud Platform.


Experiment easily. Iterate quickly. Deploy responsibly. Introducing the Upsun PaaS.

A bright, new offer powered by Platform.sh—adopted (and ❤️) by 16,000+ developers, 7,000 customers, and proven over the last 8 years—Upsun provides out-of-the-box capabilities that serve as the launchpad for creative development teams’ out-of-the-box thinking. A single, fully managed, self-service PaaS for development teams who just want to build their next, great application.

Links to check out: 👉 Get your free Upsun trial: https://brnw.ch/21wFxKr 👉 Learn more about Blackfire: https://brnw.ch/21wFxKp 👉 Get started with Platform.sh: https://brnw.ch/21wFxKj

Key moments: 0:00 - Intro

3:06 - The app - Architecture overview

  • Outlines the plan for the live demo: deploying a Symfony application and a React frontend with a ChatGPT wrapper using streaming.
  • Introduces their platform as a service, highlighting its launch and target audience.
  • Describes the application architecture, which consists of a Symfony API and a React frontend, with ChatGPT integration for streaming responses.

3:43 - Implementing a ChatGPT wrapper with streaming in Symfony

  • Demonstrates the project structure with two subfolders: frontend (React) and backend (Symfony).
  • Focuses on the backend, specifically the message controller handling requests and responses.
  • Discusses optimizing response time by implementing streaming with Symfony’s stream response.
  • Emphasizes the importance of flushing the response to ensure immediate content delivery.
  • Proceeds to test the application locally, showing the interaction with the ChatGPT model.

18:14 - First deploy on Upsun

  • Initiates the deployment process by creating a new project on their platform as a service using Symfony CLI.
  • Discusses selecting the deployment region based on environmental considerations, such as carbon footprint.
  • Demonstrates the project initialization using Symphony’s project init feature to create configuration.
  • Explains the project configuration process, including routing and specifying application details.
  • Commits the configuration to the repository and deploys the project using Symphony’s deploy command.
  • Shows how environment variables, such as the OpenAI key, are managed and updated for proper communication.

19:10 - Performance concerns

  • Testing and Deployment: After deploying the project, initial testing is done, starting with basic API requests and verifying autogenerated hostnames for different environments.
  • Streamlining Responses: The process of receiving responses from OpenAI, buffering, and restreaming them to the frontend is discussed. The inefficiency of this method in handling high traffic is highlighted, leading to scalability concerns.
  • Resource Optimization: Strategies to optimize resources are explored, such as adjusting container allocation and CPU/RAM usage based on demand.
  • Observability and Profiling: Utilizing tools like Blackfire for profiling and monitoring performance is emphasized, with a focus on identifying bottlenecks like synchronous processes.

20:56 - Scaling the application

  • Dynamic Resource Allocation: Upsun allows easy scaling up or down by adjusting CPU and RAM allocations through simple API calls or CLI commands.
  • Automated Scaling: Discussion on automated scaling strategies, including triggers based on metrics like response time and traffic spikes.
  • Flexible Scaling Strategies: Customizable scaling strategies are explained, focusing on horizontal scaling for stateless instances and vertical scaling for databases.

24:04 - How can Upsun help you

  • Ease of Use: Upsun is positioned as a user-friendly platform, offering quick onboarding and deployment processes, suitable for both testing and production applications.
  • Feedback and Improvement: Users are encouraged to provide feedback on the platform’s usability, technical aspects, pricing, and product features.
  • Future Developments: Plans for future updates include enhancements in blue-green deployment, scaling mechanisms, and improvements in permission and authentication features.

26:02 - Questions 32:42 - Ending

Last updated on