你如何横向扩展Discourse?

Hi there,
I’m confused by the installation instructions. Is there a way to scale discourse horizontally?
For ex: having 2+ docker containers on different servers each running discourse?

In the instructions from GitHub - discourse/discourse_docker: A Docker image for Discourse

The multiple container configuration setup is far more flexible and robust, however it is also more complicated to set up. A multiple container setup allows you to:

  • Minimize downtime when upgrading to new versions of Discourse. You can bootstrap new web processes while your site is running and only after it is built, switch the new image in.
  • Scale your forum to multiple servers.
  • Add servers for redundancy.
  • Have some required services (e.g. the database) run on beefier hardware.

If you want a multiple container setup, see the data.yml and web_only.yml templates in the samples directory. To ease this process, launcher will inject an env var called DISCOURSE_HOST_IP which will be available inside the image.

Is there a place where I can find more info on how I can run the containers on different servers, and not many containers on the same server?

Thanks

There is a lot of related discussion on Can Discourse ship frequent Docker images that do not need to be bootstrapped?.

The gist of it is:

  1. You provide external services for PostgreSQL, Redis and Load Balancer and configure the app.yml to use those, like for example Running Discourse with a separate PostgreSQL server.

  2. Run ./launcher bootstrap app somewhere. This will result in a container image being created in the local machine. Upload this image to your container registry service.

  3. Now you can spin as many instances as you want, telling all to run the image exported in the previous step.

4 个赞

You can do something like Running Discourse docker alongside Apache and create two web containers with something being a reverse proxy in front.

You can use multisite to have a single container serving multiple sites (using the same plugins and Discourse version). This describes how to do that without an external reverse proxy. If you try that, please leave a comment there and let me know whether it worked. I intend to post it here when I am fairly certain it works.

Running containers on multiple servers is the same as any of the above. You’d have multiple containers sharing the same Redis and Postgres running behind a load balancer.

Mostly doing anything other than the Discourse official Standard Installation is unsupported because there are infinite numbers of ways to do those things.

我有两个问题:

  • 第一个关于 Sidekiq,在运行多个 web_only.yml Docker 并且每个都在不同的虚拟机中时:在这种第一种情况下,共享同一 Redis 服务器的不同 Sidekiq 实例可能会运行相同的作业两次,Discourse 对这种错误是否健壮?使用一个 Sidekiq 在专用 VM(或 Docker)中是否更可靠,如何将其与 web_only Discourse 分开?
  • 关于您对支持的安装的最后 remarks:我明白人们可以有无限种方式来配置多个容器,但依我之见,我们需要一种受支持的方式来运行多个实例以实现水平扩展或/和高可用性,这两种情况是:基于 VM(不同 VM 中的不同 Discourse web_only Docker,Redis/Postgres 直接安装在其他单独的 VM 中,不使用 Docker)和基于容器(所有内容都基于容器)。