Score:1

How to host an app for multiple customers?

cn flag

I built a web app with NextJS that I sell b2b, where users (my clients customers) can check in to a location. They provide their name and get a check in number. The app shows client related information (opening hours, address,…)

Second part of the app is an admin panel for my clients to login and see all names and check in numbers and can provide more information.

Currently I am in beta phase and my clients are friend‘s companies, but the app is scaling very well and I need a better approach than the following:

  • my customer buys a VPS and a domain
  • I install a LEMP stack
  • I proxy the domain in nginx to localhost:3000
  • I configure the database to store the customers
  • I copy the root of my app to the server and run it (npm run build && npm run start)

I do this for every customer (currently 25). When there is a new customer, or an update of the app, it is hard manual work. Very important is, that my clients customer don’t see that there are other companies using my app.

What I want to accomplish now is the following idea and I want to know of there is a better approach or if this is good practice:

  • I want to scale to 500+ clients
  • I use my own VPS
  • Each client gets a subdomain of my own domain (this is okay for my clients)
  • My clients don’t need extra servers anymore
  • I create a table in my MySQL database with the client information (opening hours, address,…)
  • In the Nextjs app I detect the subdomain and query my database
  • I have one table for checked in customers related to the configuration table
  • I start one instance of my app
  • I locate all subdomains to that one instance
  • My clients have one admin login screen and once logged in they load the data related to the login (using JWT so that clients can’t get data from other clients)
  • For new customers I just add a new subdomain and one MySQL row and they are ready to go. This is easy to manage and if there is an update, I just update my one instance of the app.
ua flag
Sorry, but you are reinventing a well-implemented app. Your Question shows that you have a lot of work to do - more than be discussed in a single Question here.
jp flag
You need to look into the Multi-Tenant application pattern.
Score:0
ar flag

You should probably look into a cloud hosting solution, such as Azure.

I'd suggest looking into containerizing your app, and linking it to a external database of your liking. Azure, AWS and Google all support running a docker container with your app inside it - this is more or less what containers are made for.

You can script the creation of resource in all cloud services, so you can have simple 1-click setup for onboarding.

Combined with a private repository for docker images, this can streamline updating the app as well, so maintenance is less of a headache.

Exact details of how to set this up largely depends on how your app is structured.

PhilHarmonie avatar
cn flag
I don’t know how containerizing would look like, but it sounds like that a new client again takes same time to get ready. Everything more like creating a new subdomain and a MySQL entry for the clients config is too much to do for a scale. With a wildcard domain I could even avoid the subdomain creation and it’s just a post to my database and done. But is this a solid trustworthy approach?
vidarlo avatar
ar flag
Sure, you could run multiple customers on one container if you want. But I'd argue in favour of separating customers as far as possible, and containerization can minimize the setup time.
PhilHarmonie avatar
cn flag
When each app runs in a different container, they all run on different ports. Thus, I need to take care of mapping subdomain, and port and config. It’s one level more, that I need to take care of, correct?
vidarlo avatar
ar flag
It depends. If you run it on a cloud providers service, they will take care of that magic. If you run with your own box you'd need a reverse proxy or similar in front of it.
PhilHarmonie avatar
cn flag
I want to prefer my VPS. I can proxy there with nginx.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.