Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

fazofazaal's avatar

Multiple databases + Laravel App in single AWS EC2 instance.

I'm developing a Laravel application that serves to 3 different marketplace on separate domains, for bikes, cars, and boats with grouped routes, controllers, views and models per each domain. Idea is to have 3 websites served by a single server side app that shares authentication and User model etc.

For the application, I need to have linked tables for bikes, cars and boats. So ideally, how I'm thinking to structure the app is:

  • App DB: hosts tables for users and other common entity tables.
  • Bikes DB: hosts all the makes, models, and specifications of different bikes
  • Cars DB: hosts all the makes, models, and specifications of different cars
  • Boats DB: hosts all the makes, models, and specifications of different cars

I'm aware that Laravel can configure the use of multiple databases and set cross-DB Eloquent relationships so that technical aspect is understandable for me. However, as a self funded project, my target is to start with a single EC2 instance.

Question is: Will it affect the performance of the application if I query across multiple databases that runs within the same instance as that of the application itself? Hoping for some suggestions as well. Thanks!

0 likes
3 replies
bugsysha's avatar

When (if ever) you hit that performance issue your app will enable you to hire smart people which will worry about that for you. So answer is no it will not affect performances if you query across multiple databases.

1 like
fazofazaal's avatar

Thank you for the input. Do you think having multiple separated DBs in this context is a better approach than having one consolidated DB with prefixed table names?

bugsysha's avatar

It looks to me as if you are trying to solve application layer issue through persistence layer. Your app should be agnostic about those things. So if tomorrow you want to create another app for airplanes, or drones you can just spin up new db and that is it.

Please or to participate in this conversation.