我已经建立了可以在2个8GB盒子中运行的喷雾服务。它每5秒接收一次Json,它将被转换为MyJsonMessage。每个MyJsonMessage将包含3000个MyObjects。因此,每隔5秒就会创建3000个MyObjects。
在内部我使用批处理来处理这1000个批次的3000个对象,这些对象将被发送到consumerActor。
我的堆大小设置为5GB。
我正在发布指标。我已经看到YGC时间以非常高的速度增长,甚至堆大小增加并经常接触5 GB。我是Akka的新手所以我不确定这里是否有任何内存泄漏或只有选项是添加更多的框。解决方案/建议?
case class MyJsonMessage
(
inputString1:String,
inputString2:String,
objectList:List[MyObject]
)
case class MyObject
(
objectName : String,
objectValue : String,
data : Map[String,String]
)
class MyHttpService (implicit val context: akka.actor.ActorRefFactory
.....) extends MyJsonProtocol
{
def worker = MyHttpServiceWorker
val multicastRoute = path("service" / "task" / segment) {
(configName: String) => {
post { ctx =>
var payload = try {
Left(JsonParser(ctx.request.entity.asString).convertTo[MyJsonMessage])
} catch {
case ex: Exception =>
log.error("Error converting message payload: ", ex)
Right(ex)
}
worker.process(payload.left.get)
}
object MyHttpServiceWorker
{
def process[T](request: T) = {
request match {
case request : MyJsonMessage =>
val objectListCount = request.objectList.size
val batches = objectListCount > 1000 match {
case true => ceil(objectListCount * 1.0 / 1000).toInt
case false => 1
}
List.range[Long](0, batches).foreach(batch => {
val split = MyBulkObjectRequest(request, batch.toInt *
batchSize, limit * batchSize)
MyObjectRequestConsumer ! split
limit += 1
})
MyObjectSuccessResponse(objectListCount, batches, requestId , UUID))
}
}
以下是conf
中MyObjectRequestConsumer的调度程序myobject-dispatcher {
type = Dispatcher
executor = "fork-join-executor"
fork-join-executor {
parallelism-min = 16
parallelism-factor = 4.0
parallelism-max = 16
}
throughput = 1
}