回廊->简单的OTP集群管理

几乎每个成功的业务应用程序迟早都需要进入水平扩展阶段。在许多情况下,您可以简单地启动一个新实例并减少平均负载。但是,在很少的情况下,我们必须确保不同的节点彼此了解并准确地分配工作负载。


回廊


碰巧的是,我们之所以选择erlang,是因为它具有不错的语法和炒作,它对分布式系统具有一流的支持从理论上讲,这听起来很琐碎:


在不同节点上的进程之间以及在链接和监视器之间的消息传递是透明的[...]

实际上,事情要复杂一些。分布式erlang是在“容器”意味着如此大的铁箱进行运输而“码头工人”只是港口装载机的同义词时开发出来的。IP4中,网络间隙中有许多未占用的地址-通常是被咬的老鼠被指责,而且生产系统的平均正常运行时间长达数十年。


, , erlang , IP- , . , erlang, , .


: libcluster. , ,  — , .  —  . , , . .



, , :


  • , erlang;
  • ( , , , );
  • , :nonode@nohost;
  • , .

, , :nonode@nohost, - test_cluster_task, docker-compose up --scale my_app=3 , - . , , mnesia — , - .


Cloister , : . , , , CS . , . , .



Cloister , (assembly and maintainance) , Cloister.Manager .


, config, :


config :cloister,
  otp_app: :my_app,
  sentry: :"cloister.local", # or ~w|n1@foo n2@bar|a
  consensus: 3,              # number of nodes to consider
                             #    the cluster is up
  listener: MyApp.Listener   # listener to be called when
                             #    the ring has changed

: Cloister OTP :my_app, erlang service discovery , , MyApp.Listener ( @behaviour Cloister.Listener) . .


, Cloister , ( , .) , , . ( , ), MyApp.Listener.on_state_change/2. , %Cloister.Monitor{status: :up}, : «, ».


consensus: 3 , , , status: :rehashingstatus: :up .


, consensus: 1 Cloister , :nonode@nohost, :node@host, :node@host.domain — , (:none | :shortnames | :longnames).



, mnesia. on_state_change/2. , , , mnesia Cloister.


Cloister , . , , , IP- , , , /. , :nonode@nohost. .


, MyApp.Listener, , . , libcluster, , . , , , -.




注意:最初,这是短语“ Happy clustering!”,而我翻译的Yandex(而不是自己攀登词典)向我提供了“ Happy cluster!”选项。最好的翻译,尤其是鉴于当前的地缘政治形势,也许是无法想象的。


All Articles