I am not sure whether octopus will be the right solution for the
problem I am trying to tackle. Let me describe what I am addressing.
I have an application, which I would like to provide for more
clients. The clients would be distinguished based on the server name/
subdomain which they access. Let's say if one accesses
, than a shard for the first client would be used by
the models, in case of client2.foo.com
the shard for the second.
My current idea how to approach this is this:
1) I catch and store the actual request to the current thread:
Thread.current[:current_request] = request. This catching could be
done at different places.. middleware, application/action controller
or maybe by routing.. I did not decide yet which would be the best
2) When one tries to access a model, it behaves differently based
on the server name, the current request comes from, i.e. uses a
different shard for different server name in the request.
- When there is no http request (the model is accessed from
console,etc.) it will be necessary to think over, what to do, I did
not decide on the strategy yet here too.
There are things I would like to know about octopus.
- creating shards dynamically - the new applications for the
clients would be necessary to create dynamically. So I will need to
create the shards during the execution of the application... Probably
this means using something like https://github.com/tchandy/octopus/wiki/Dynamic-shard-configuration
but not in the initializer but rather in a controller action. The
changes on shards would be necessary to be incremental. How to do this
- I am thinking that creating a multi-app based solution would
be initially realized on a single database (for relational db based
models), where the tables would have different prefix. Is it possible
to define a shard using a table prefix?
- Did anyone try octopus with Heroku? I am asking that, because
Heroku needs to be configured through its variables to access the Db,
database.yml is not considered by Heroku. And I don't know what
pitfalls could come on the way when I would try to deploy an app with
octopus on Heroku.
I am still not quite sure, whether octopus is the right tool for
the job. I like to way how octopus works and is implemented very much.
However, if you think I am trying to use it for an unintended purpose,
please refer me to another solution. Maybe I am trying to shot a
mosquito with a cannon, and the right solution is much simpler.
Thank you very much for the answer and any suggestions.