Initialize TransportClient in a web application


(Spico Florin) #1

Hello!
We have a cluster with 10 Elastic Search nodes that we are using for
indexing our data. In order to perform searching, we are using a web
application(deployed on Tomcat web server) installed on a machine that
will be remote from ES. Therefore, we are using TransportClient in
order to connect to ElasticSearch.
But in order to do that in the right way, we would like to ask you
what is the best way to initialize this connection:

  1. Adding all the ElasticSearch nodes to the TransportClient (using API)
  2. In order to discover the ES network, what do you recommend :
    Unicast or Multicast?
  3. Where in the web application we should do this connection to ES ?
    Can we use the ThreadLocal Pattern into a Singleton class and from
    there to create the connection? Or we can initialize this connection
    from ServletContextListener?

Thank you in advance.
Kind regards,
Florin


(Shay Banon) #2

On Tuesday, June 14, 2011 at 11:15 AM, Spico Florin wrote:

Hello!
We have a cluster with 10 Elastic Search nodes that we are using for
indexing our data. In order to perform searching, we are using a web
application(deployed on Tomcat web server) installed on a machine that
will be remote from ES. Therefore, we are using TransportClient in
order to connect to ElasticSearch.
But in order to do that in the right way, we would like to ask you
what is the best way to initialize this connection:

  1. Adding all the ElasticSearch nodes to the TransportClient (using API)
    It is recommended to add as many addresses as you know to it. You can also enable sniffing so it will sniff the other nodes automatically.
  2. In order to discover the ES network, what do you recommend :
    Unicast or Multicast?
    You mean for the cluster? Transport client always uses "unicast". As for the cluster, its up to you.
  3. Where in the web application we should do this connection to ES ?
    Can we use the ThreadLocal Pattern into a Singleton class and from
    there to create the connection? Or we can initialize this connection
    from ServletContextListener?
    Up to you, as long as you don't create several client instances.

Thank you in advance.
Kind regards,
Florin


(system) #3