Domanda

La mia applicazione effettua richieste Web Service; v'è un tasso massimo di richieste il provider di gestire, quindi ho bisogno di strozzare giù.

Quando l'applicazione riceve un singolo server, che ho usato per farlo a livello di applicazione: un oggetto che tiene traccia di quante richieste sono state fatte finora, e aspetta se la richiesta attuale rende supera il carico massimo consentito .

Ora, stiamo eseguendo la migrazione da un singolo server a un cluster, quindi ci sono due copie della applicazione in esecuzione.

  • Non riesco a mantenere il controllo per il carico massimo al codice dell'applicazione, in quanto i due nodi combinati potrebbero superare il carico consentito.
  • Non può semplicemente ridurre il carico su ciascun server, perché se l'altro nodo è inattivo, il primo nodo può inviare più richieste.

Questo è un ambiente JavaEE 5. Qual è il modo migliore per strozzare le richieste l'applicazione invia?

È stato utile?

Soluzione

Se la libreria è stata cancellata in errore dall'utente, non è possibile ripristinare questo dal cestino della raccolta del riciclo?

Altri suggerimenti

Many ways of doing this: you might have a "Coordination Agent" which is responsible of handing "tokens" to the servers. Each "token" represents a permission to perform a task etc. Each application needs to request "tokens" in order to place calls.

Once an application depletes its tokens, it must ask for some more before proceeding to hit the Web Service again.

Of course, this all gets complicated when there are requirements with regards to the timing of each calls each application makes because of concurrency towards the Web Service.

You could rely on RabbitMQ as Messaging framework: Java bindings are available.

I recommend using beanstalkd to periodically pump a collection of requests (jobs) into a tube (queue), each with an appropriate delay. Any number of "worker" threads or processes will wait for the next request to be available, and if a worker finishes early it can pick up the next request. The down side is that there isn't any explicit load balancing between workers, but I have found that distribution of requests out of the queue has been well balanced.

The N nodes need to communicate. There are various strategies:

  • broadcast: each node will broadcast to everybody else that it's macking a call, and all other nodes will take that into account. Nodes are equal and maintain individial global count (each node know about every other node's call).
  • master node: one node is special, its the master and all other nodes ask permission from the master before making a call. The master is the only one that know the global count.
  • dedicated master: same as master, but the 'master' doesn't do calls on itslef, is just a service that keep track of calls.

Depending on how high do you anticipate to scale later, one or the other strategy may be best. For 2 nodes the simplest one is broadcast, but as the number of nodes increases the problems start to mount (you'll be spending more time broadcasting and responding to broadcats than actually doing WS requests).

How the nodes communicate, is up to you. You can open a TCP pipe, you can broadcats UDP, you can do a fully fledged WS for this purpose alone, you can use a file share protocol. Whatever you do, you are now no longer inside a process so all the fallacies of distributed computing apply.

Medes,

Prima di tutto, nell'esempio quando viene creata la scheda di discussione , La linea che ottiene l'istanza della scheda di discussione appena creata è mancante, quindi credo che sia necessario aggiungerla dopo la riga

$web.Lists.Add($listName, "Riksrevisonens diskussions forum", [int]$listTemplate)
.

come questo

$list = $web.Lists[$listName]
.

E l'ultimo, quando aggiungi la scheda di discussione usando la GUI, in realtà è istanziata utilizzando xsltlistviewwebpart e non listviewwebpart .
Quindi se si cambia la linea in cui viene creata la web part con questo:

$ListViewWebPart = New-Object Microsoft.SharePoint.WebPartPages.XsltListViewWebPart
.

Sarebbe Aggiungi scheda di discussione sulla pagina come ti aspetti che .

Spero che questo aiuti,

vadim

Hystrix was designed for pretty much the exact scenario you're describing. You can define a thread pool size for each service so you have a set maximum number of concurrent requests, and it queues up requests when the pool is full. You can also define a timeout for each service and when a service starts exceeding its timeout, Hystrix will reject further requests to that service for a short period of time in order to give the service a chance to get back on its feet. There's also real time monitoring of the entire cluster through Turbine.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top