Sunspot Sharding setup

289 views
Skip to first unread message

Chris Rode

unread,
Feb 2, 2011, 7:54:11 AM2/2/11
to Sunspot
I am using Sunspot in a Rails application and I have a few questions
in scaling it up to move to a production environment. For clarity I
will post the questions in separate threads

This question is about the ShardingProxies in Sunspot. I have not seen
any documentation on how to hook this into a rails project. Can anyone
point me in the right direction?

Matthew A. Brown

unread,
Feb 2, 2011, 8:02:34 AM2/2/11
to ruby-s...@googlegroups.com
Hi Chris,

Before we get into the details on using ShardingSessionProxy, a couple
of questions:

* Are you *sure* you need to shard? Sharded Solr setups are usually
called for only if you have a truly massive amount of data in your
index. If you're just looking to scale up the amount of traffic Solr
can handle, replication is your best tool.
* Assuming the answer to the above is "yes", on what basis do you want
to shard your data? By class? Geography?

Mat

> --
> You received this message because you are subscribed to the Google Groups "Sunspot" group.
> To post to this group, send email to ruby-s...@googlegroups.com.
> To unsubscribe from this group, send email to ruby-sunspot...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ruby-sunspot?hl=en.
>
>

Chris Rode

unread,
Feb 2, 2011, 1:07:27 PM2/2/11
to Sunspot
Hi Matthew

Thanks for your quick reply. In answer to your question: No, I
probably wont need sharding for my existing project, however I am very
interested in sunspot's ability to cater for this for future
reference.

Given that I don't have a use case for it yet, it doesn't really
matter what sort of sharding takes place in the example. I see that
Sunspot has an inbuilt IDShardingProxy class. Is it possible to
provide an example of how that might be wired into a Rails project?

Chris

Matthew A. Brown

unread,
Feb 2, 2011, 1:33:38 PM2/2/11
to ruby-s...@googlegroups.com
Hi Chris,

You'd want to put something along these lines in an initializer:

shard_sessions = (1..4).map do |i|
session = Sunspot::Session.new
session.config.solr.url = "http://solr-#{i}.myhost.com"
Sunspot::SessionProxy::ThreadLocalSessionProxy.new(session)
end

Sunspot.session = Sunspot::SessionProxy::IdShardingSessionProxy.new(
Sunspot.session, shard_sessions)

IdShardingSessionProxy is more of an example than something intended
for use as-is in a real application -- you're generally better off
implementing your own session proxy which shards based on some sort of
natural distinguisher.

Mat

Amit....@infibeam.net

unread,
May 21, 2013, 9:14:16 AM5/21/13
to ruby-s...@googlegroups.com
Hii Guys,
i am using sunspot solr for my website and it is working fine for single database, now i had multiple websites with multiple databases (database schema is same for all but only data is different for different clients), how can i setup a single Rails Solr Project so that it will use same code with different databases, how to maintain different index files etc..... please help me out i m in a mess.............Thanx in advance
Reply all
Reply to author
Forward
0 new messages