2016-05-08 5 views
2

Ich versuche Parallelität in einem Rails Puma-Server auf Entwicklung zu erreichen, aber in Schwierigkeiten geraten.Rails Puma Concurrency Problem

Mein Endpunkt wie folgt aussieht:

def show 
     (1..10).each do |i| 
     Rails.logger.info "I!! #{i}" 
     sleep(1) 
     end 
     render json: {health: "hihi"} 
    end 

ich diesen Endpunkt zweimal getroffen laufen, eine nach der anderen, und sie laufen in Folge. Kann ich sie dazu bringen, mehr gleichzeitig zu sein?

Log:

puma -t 2:16 -p 3000 
    [20186] Puma starting in cluster mode... 
    [20186] * Version 3.4.0 (ruby 2.2.2-p95), codename: Owl Bowl Brawl 
    [20186] * Min threads: 2, max threads: 16 
    [20186] * Environment: development 
    [20186] * Process workers: 2 
    [20186] * Preloading application 
    [20186] * Listening on tcp://0.0.0.0:3000 
    [20186] Use Ctrl-C to stop 
    [20186] - Worker 0 (pid: 20217) booted, phase: 0 
    [20186] - Worker 1 (pid: 20218) booted, phase: 0 

    Started GET "/v1/address-service/addresses/1" for 127.0.0.1 at 2016-05-07 19:00:38 -0700 
     ActiveRecord::SchemaMigration Load (0.5ms) SELECT `schema_migrations`.* FROM `schema_migrations` 
    Processing by Api::V1::AddressService::AddressesController#show as JSON 
     Parameters: {"id"=>"1"} 
    I!! 1 
    I!! 2 
    I!! 3 
    I!! 4 
    I!! 5 
    I!! 6 
    I!! 7 
    I!! 8 
    I!! 9 
    I!! 10 
    Completed 200 OK in 10143ms (Views: 0.9ms | ActiveRecord: 0.0ms | Elasticsearch: 0.0ms) 


    Started GET "/v1/address-service/addresses/1" for 127.0.0.1 at 2016-05-07 19:00:49 -0700 
    Processing by Api::V1::AddressService::AddressesController#show as JSON 
     Parameters: {"id"=>"1"} 
    I!! 1 
    I!! 2 
    I!! 3 
    I!! 4 
    I!! 5 
    I!! 6 
    I!! 7 
    I!! 8 
    I!! 9 
    I!! 10 
    Completed 200 OK in 10031ms (Views: 0.3ms | ActiveRecord: 0.0ms | Elasticsearch: 0.0ms) 

development.rb:

config.cache_classes=false 
    config.allow_concurency = true 
+0

Meine Schienenversion ist: Schienen 4.2.5.2 – Gary

Antwort

0

Ich weiß, ich Chrom wurde mit testen und es sendet nur eine Anforderung zu einem Zeitpunkt, zu welchem ​​Grund auch immer. Ich habe Curl benutzt und es funktioniert wie erwartet.