On 08/05/2010 8:30 PM, Jeremy Evans wrote:
The current (default) shard is connected to a template database to
initialize all the models. This is done just once at program start.
We then switch databases at runtime by connecting the "current" shard
to a different database and use all the models. This *seems* to work
just fine for retrieving and saving to the current shard. Is there
something that won't work in this case that I might get bitten by?
It's not thread safe. The correct way would be to set the shard to
use manually on each dataset. However, depending on how your code is
structured, that may be a lot of work.
A lot of work indeed. We have 182 models. Obviously not all of them are
used on every web request, but it would be a daunting task, as well as
error prone, to set every used model's dataset on each request.
It's possible you'll run into issues, though I can't think of any
right now. If thread safety isn't important, it may be a valid
approach.
We're using Sinatra but with the "lock" option set to only process one
request at a time as we have other libraries that are not entirely
thread safe. We then use a cluster of Sinatras fed by nginx at the front
end, so it should be thread safe in that sense.
Thanks,
Gary.
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en.