kriasoft / react-starter-kit

The web's most popular Jamstack front-end template (boilerplate) for building web applications with React

Home Page:https://reactstarter.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Separate API server and database from feature/apollo-pure webserver

Filco306 opened this issue · comments

First of all, huge thanks for this repo; it has helped me a lot during my development of my web application. I have successfully managed to deploy my application to AWS Elastic Beanstalk using a dockerized deployment.

I am however at the stage where I am to integrate the database and the GraphQL part of the repo, and I am dumbfounded on where to start. A few question, and please excuse me as this is not an issue with the repo, but rather help I need to get started using the GraphQL part of the repo with questions I have looked for answers but haven't found.

  • I think the best solution is to separate the GraphQL server API from the actual server to balance loads, correct? Does anyone have experience doing this and getting it into production?
  • Can I choose to use a PostgreSQL database in conjunction with the GraphQL API instead of SQLite?
  • How do I separate the database, so it is not stored inside the docker container? Is it simply pointing to another dataBaseUrl set in config.tsx?

Again, sorry for the noob questions, but I really need some help getting started with this.

Thanks!

Managed to answer most of these questions myself.

Belatedly please allow me to leave my thoughts to your questions.

server to balance loads

In my opinion, you don't have to. I'd recommend you to think about these.

  • You can try Load Balancer, where it proxies requests to multiple servers of the React Starter Kit app. This means you don't have to split SSR and GraphQL API anymore with the ability to scale as much as you want.
  • Splitting SSR and GraphQL API is good for balancing CPU usage, because of Node's single-threaded architecture as you know. But how about trying Clustering first? If your server has multiple cores (I'm sure it will), theoretically it can scale by a multiple of the number of the cores.
  • The current "calling GraphQL API from SSR" is optimized; it doesn't send HTTP requests thanks to Apollo's SchemaLink. If you split it into servers, of course, you'll need HTTP requests for that.

PostgreSQL

Yes, of course. It's up to you how to implement GraphQL resolvers.

separate the database

You're guessing correct.

Hello @piglovesyou ,

Thank you very much for your response. You are entirely right in what you say. I had a hard time getting started, but I seem to be on track now. Again, thank you for your patience and help! It is very highly appreciated!