【发布时间】:2016-07-08 14:45:38
【问题描述】:
我正在使用 akka-http,我的 build.sbt 配置是:
scalaVersion := "2.11.7"
libraryDependencies += "com.typesafe.akka" % "akka-actor_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-http-experimental_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-http-spray-json-experimental_2.11" % "2.4.2"
libraryDependencies += "com.typesafe.akka" % "akka-slf4j_2.11" % "2.4.2"
我正在公开一个只有一个 GET url 的简单 REST api
foo 是一个返回 Future 的函数
implicit val actorSystem = ActorSystem("system", config)
implicit val actorMaterializer = ActorMaterializer()
val route: Route = {
get {
path("foo") {
complete { foo }
}
}
}
web-service 预计会有很多调用,我想让服务在失败的情况下冗余,所以我想让两个实例同时运行来处理所有请求.
1) 让两个 web 服务实例同时处理请求的最佳方式是什么?使用外部负载均衡器或在 akka/akka- 中使用一些魔法(我不知道) http ?
2) 为了提高性能,我必须调整哪些主要参数?
【问题讨论】:
标签: scala akka akka-stream akka-http