Lucene.net Server Farm / Multiple Servers

Question!

I haven't thought about this issue before as I was hosting the application on just one windows server 2008 and lucene.net stores the index on its local hard drive.

(Basically, every time, when a user post something or reply something, I update the index, so the search can return the latest result. Not sure if that's the best way to do it)

Now that we are going to need another webserver with a load balancer in front, I obviously can't have each sever index their own depends on where load balancer points to, as they will be out of synch.

One option for me is to hook up the two servers and map them to a shared server that stores the indexes, but is that a suggested solution?

How do you guys managed the parsing and indexing of lucene.net in a server farm environment?

Thanks a lot



Answers

You could seperate the Lucene index engine from your web application by creating a service that delivers the functionalities, something like a WCF or Rest service.

You can also use already existing search servers.

http://lucene.apache.org/solr/

http://www.elasticsearch.org/



The way we keep our load-balanced servers in sync, each with their own copy of Lucene, is to have a task on some other server, that runs every 5 minutes commanding each load-balanced server to update their index to a certain timestamp.

For instance, the task sends a timestamp of '12/1/2013 12:35:02.423' to all the load-balanced servers (the task is submitting the timestamp via querystring to a webpage on each load-balanced website), then each server uses that timestamp to query the database for all updates that have occurred since the last update through to that timestamp, and updates their local Lucene index.

Each server also stores the timestamp in the db, so it knows when each server was last updated. So if a server goes offline, when it comes back online, the next time it receives a timestamp command, it'll grab all the updates it missed while it was offline.

By : Doug S


This video can help you solving your question :)
By: admin