Some Background
- Last year, the entire Sugar-AI platform (frontend and backend) ran on a single 24/7 AWS EC2 instance. This led to burning through cloud credits because we pay hourly rates even when no one was using the AI.
- To fix this simply and with using open-source models, we will split the application into two parts: a 24/7 free frontend, and an auto-sleeping backend.
Plan
- Frontend on GitHub Pages (Free & Always On): The website UI will be extracted and hosted statically on GitHub Pages. Even if the backend AI server is turned off to save money, users will still see the website.
- Backend on EC2 (Auto-Sleeping): The heavy FastAPI/PyTorch backend stays on EC2, but we configure it to automatically turn itself off after 30 minutes of inactivity.
- The "Wake Up" Button: To turn the server back on, the GitHub Pages UI will have a "Start AI Server" button. Clicking this hits a single, extremely simple AWS Lambda URL that starts the EC2 instance if it's turned off, that is if the user faces any issues if using the AI chat from the UI itself.
Tasks
Phase 1: Decouple Frontend & Database calls to GitHub Pages
Phase 2: Implement "Auto-Sleep" for the Backend
Phase 3: Implement the "Wake Server" Button
Finally:
Final Acceptance
Discussions
- Because this will be public, we might still run into issues if someone decides to keep a bot to click our wake up button. To solve this we should add a shared secret X-Wake-Token like, which bots discovering would not have but the GH pages JS when Humans interact should be able to send it. For stronger protection, reserved concurrency throttling on the Lambda can be added as a second layer because someone smart can still lookup the token as it will be public or we can have a private repository to host the site.
Some Background
Plan
Tasks
Phase 1: Decouple Frontend & Database calls to GitHub Pages
Phase 2: Implement "Auto-Sleep" for the Backend
Phase 3: Implement the "Wake Server" Button
Finally:
(When clicked, users will wait ~2-3 minute for the EC2 to boot up).
Final Acceptance
Discussions