Created
April 2, 2014 22:26
-
-
Save kenichi/9944480 to your computer and use it in GitHub Desktop.
using sinatra/puma to test long-wait calls to other services from angelo/reel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ be ruby concurrency_test_app.rb -p 5000 | |
I, [2014-04-02T15:15:12.467887 #1602] INFO -- : Angelo 0.1.5 | |
I, [2014-04-02T15:15:12.468080 #1602] INFO -- : listening on 127.0.0.1:5000 | |
D, [2014-04-02T15:15:27.794593 #1602] DEBUG -- : 127.0.0.1 - - "GET /asynch_test HTTP/1.1" 200 11 | |
D, [2014-04-02T15:15:28.887823 #1602] DEBUG -- : 127.0.0.1 - - "GET /asynch_test HTTP/1.1" 200 11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'angelo' | |
require 'http' | |
class ConcurrencyTestApp < Angelo::Base | |
get '/asynch_test' do | |
HTTP.get('http://localhost:4567/wait', socket_class: Celluloid::IO::TCPSocket).response.body | |
end | |
end | |
ConcurrencyTestApp.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
get '/wait' do | |
sleep 5 | |
'hello world' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby sin_wait.rb -o 127.0.0.1 | |
Puma 2.7.1 starting... | |
* Min threads: 0, max threads: 16 | |
* Environment: development | |
* Listening on tcp://127.0.0.1:4567 | |
== Sinatra/1.4.4 has taken the stage on 4567 for development with backup from Puma | |
127.0.0.1 - - [02/Apr/2014 15:15:27] "GET /wait HTTP/1.1" 200 11 5.0065 | |
127.0.0.1 - - [02/Apr/2014 15:15:28] "GET /wait HTTP/1.1" 200 11 5.0015 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ date +'%s' ; time curl http://localhost:5000/asynch_test | |
1396476922 | |
hello world | |
real 0m5.032s | |
user 0m0.006s | |
sys 0m0.004s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ date +'%s'; time curl http://localhost:5000/asynch_test | |
1396476923 | |
hello world | |
real 0m5.014s | |
user 0m0.006s | |
sys 0m0.004s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
note that the timings in the terms are a second apart, yet each took 5s to finish (not 5 on first and 10 on second as previous attempts)