Thanks Jeremy;
So if I am using JRuby/Sinatra on Community Passenger I will need to
basically close/disconnect my newly initialized connections basic example
of config.ru
openedge_jdbc_uri = {
:adapter => 'jdbc',
:username => 'someuser',
:password => 'somepassword',
:driver => 'com.ddtek.jdbc.openedge.OpenEdgeDriver',
:url =>
'jdbc:datadirect:openedge://somedbserver.bogus.com:7910;databaseName=customer'
,
:pool_timeout => 120,
:max_connections => ENV['RACK_ENV'].to_s.downcase == 'production' ? 16 : 4
,
:convert_types => false,
:logger => $logger,
:after_connect => Proc.new{|con|
stmt = con.createStatement()
stmt.execute("SET SCHEMA 'PUB'")
}
}
DB = Sequel.connect(openedge_jdbc_uri)
DB.extension(:newrelic_instrumentation)
DB.extension(:connection_validator)
DB.extend_datasets(Sequel::Progress::DatasetMethods)
# Invalidate connection if idle for 1/2 hour
DB.pool.connection_validation_timeout = 1800
DB.extend_datasets(SequelProgessTenDatasetMethods)
DB.disconnect
run MyAwesomeWebService
I have one more question: In the above code I set a pool size of 16. Now
if I am deployed on a Passenger JRuby Sinatra stack and Passenger allocates
5 Processes(Forked) I would end up with 5 x 16 = 80 db connections?
Further more because now we can only handle 5 concurrent requests (5
Processes) I am only using 5 of the 80 db connections?
I wonder if I really need to go to a real Java (JVM) application server?
(I don't want to do that. We are really a ruby shop. The only reason I
am using JRuby is mostly because of having to connect to OpenEdge via JDBC).
Thanks again for you help with this.
Best Regards Jeremy.
On Thursday, August 20, 2015 at 9:34:39 AM UTC-5, Jeremy Evans wrote:
>
> On Thursday, August 20, 2015 at 7:28:28 AM UTC-7, Dale Ackerman wrote:
>>
>> (I placed this same question to the Passenger group)
>>
>> I am confused by the many posts and other documents and posts regarding
>> how passenger works with JRuby (fork process or spawn thread) and how that
>> impacts non rails(ActiveRecord) connection pools. I have inherited a bunch
>> of ruby (rails/sinatra) applications all running on some combination of
>> Apache2 and passenger both ruby/jruby. I am not convinced that the
>> configurations are correct. So I need to understand the facts regarding DB
>> connection pool sharing (if it does) and the differences in methods used
>> for allocating threads (JRuby JVM) and or forking new OS processes.
>>
>> stack #1
>> ------------------------------------
>> Apache2
>> Passenger 4/5
>> JRuby
>> Sinatra
>> Sequel ORM (jdbc drivers)
>>
>> stack #2
>> ------------------------------------
>> Apache2
>> Passenger 4/5
>> MRI Ruby 1.9 - 2.2.2
>> Rails 3.x - 4.x
>> ActiveRecord ORM (MSSQL freeTDS drivers and some Postgresql)
>>
>> I am placing this same question to the passenger group as well. I hope
>> to find the official answer and get that posted in both projects
>> documentation.
>>
>>
>> Best Regards
>>
>
>
> If you aren't forking, you generally don't need to worry about it.
> Sequel's default connection pool is thread safe, and will work fine on
> JRuby.
>
> Thanks,
> Jeremy
>
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.