You are most likely getting these errors because of this regression in 
RC4: https://github.com/akka/akka/issues/17854

Your test should do what you expect with RC3. It would also work with RC4 
if your client had HTTP KeepAlive enabled:
> ab -n 50 -c 4 -k http://localhost:9000/test

Egis

On Sunday, 5 July 2015 14:29:07 UTC+1, Dmitry Vorobiov wrote:
>
> Hi,
>
> I am investigating akka-http as a potential replacement for spray for our 
> new microservices. There we have lots of blocking IO operations that are 
> pretty easy to handle with spray by wrapping them in Future and blocking 
> and providing a separate thread pool.
>
> I tried to test the same approach with simple Akka HTTP code: 
>
> object Main extends App with SimpleAkkaHttpMain with Logging
>
> trait SimpleAkkaHttpMain {
>   implicit val system: ActorSystem = ActorSystem()
>
>   implicit def executor: ExecutionContextExecutor = system.dispatcher
>   val endpointDispatcher = 
> system.dispatchers.lookup("akka.dispatchers.threadpool-dispatcher")
>
>   implicit val materializer: Materializer = ActorMaterializer()
>   Http().bindAndHandle(new SimpleEndpoint(endpointDispatcher).routes(), 
> "0.0.0.0", 9000)
> }
>
> class SimpleEndpoint(_context: ExecutionContext) extends Directives {
>   implicit val context = _context
>   def routes() = {
>     (get & path("test")) {
>       complete {
>         Future {
>           blocking {
>             Thread.sleep(2000)
>           }
>           "test"
>         }
>       }
>     }
>   }
> }
>
>
> Config: 
>
>
> threadpool-dispatcher {
>   type = Dispatcher
>   executor = "thread-pool-executor"
>   thread-pool-executor {
>     core-pool-size-min = 2
>     core-pool-size-factor = 2.0
>     core-pool-size-max = 100
>   }
>
> }
>
>
> I ran the following terminal command to test it:
>
> > ab -n 50 -c 4  http://localhost:9000/test
>
>
> Benchmarking localhost (be patient)...apr_socket_recv: Connection reset by 
> peer (54)
> Total of 10 requests completed
>
>
> This is what I see in logs: 
>
>
> history-api DEBUG [2015-07-05 15:24:11,403 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:11,404 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:13,426 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:13,426 CEST] SelectionHandler - Monitored 
> actor 
> [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$A#-1737469294]]
>  terminated
> history-api DEBUG [2015-07-05 15:24:13,427 CEST] SelectionHandler - Monitored 
> actor 
> [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$z#-1452647390]]
>  terminated
> history-api DEBUG [2015-07-05 15:24:16,186 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:16,186 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:16,187 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:16,187 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:18,202 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:18,208 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:18,208 CEST] SelectionHandler - Monitored 
> actor 
> [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$F#1453413388]]
>  terminated
> history-api DEBUG [2015-07-05 15:24:18,209 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:18,209 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:20,217 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:20,219 CEST] TcpListener - New connection 
> accepted
> history-api DEBUG [2015-07-05 15:24:20,223 CEST] SelectionHandler - Monitored 
> actor 
> [Actor[akka://default/system/IO-TCP-STREAM/server-1-%2F0.0.0.0%3A9000/$K#1142842464]]
>  terminated
>
>
> A similar test for Spray works smoothly. Can you please help me with advice 
> what one can do to process blocking operations in akka-http?
>
>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to