PhysarumSM / service-manager

LCA and Proxy
Apache License 2.0
0 stars 0 forks source link

Speed Up Search for Service #44

Open t-lin opened 4 years ago

t-lin commented 4 years ago

Look into ways to speed up the querying for a service. Currently takes ~5 seconds.

t-lin commented 4 years ago

Digging into the proxy code:

  1. Eliminating the continue at the end of the loop that searches for cached instances reduces unnecessary latency. It was originally used to verify that the instance is properly stored into the pcache.
  2. There's a bug in the logic of the service search loop: when AllocService() is called, it returns the ID and performance of the allocator instance that created the new container. At the end of the loop, AddPeer() then stores the allocator's identity hash and associates it with the service hash that we're looking for. Thus, the first querying for a service (that doesn't already exist) will always fail to return a proper result. Subsequent queries should work.
t-lin commented 4 years ago

Able to get querying of new service (minus the time to download the image) down to ~2 seconds now. Will look into further improvements in the future.

Also need to think about returning an appropriate status (or message) back to source proxy if the destination proxy is busy downloading a new image. Right now it just times out, making it confusing for the client. Perhaps a more friendly "try again later" with an estimated time?

t-lin commented 4 years ago

After leaving the bootstrap up and running for a long time, with dozens or hundreds of short-lived P2P nodes connecting and disconnecting during that time (even if they keep the same peer ID each time), the search can sometimes become excrutiatingly slow. It doesn't seem to be constant (ranges from almost instantaneous, to timing out).

Wondering if its keeping the history of multiaddresses of a given peer (since restarting peers changes its port number each time), and has to try connecting to each of them. Further investigation is needed.