Giter VIP home page Giter VIP logo

Comments (8)

afrind avatar afrind commented on May 25, 2024

The ServerIdleSessionController should detach the session from the connection manager by calling detachThreadLocals: https://github.com/facebook/proxygen/blob/main/proxygen/lib/http/connpool/ServerIdleSessionController.cpp#L38.

Looks like there's a little but of manual work required, some of our non-oss code has this bit:

      auto future = serverIdleSessionController_.getIdleSession();
      auto func = [=](HTTPSessionBase* session) {
        HTTPTransaction* txn = nullptr;
        if (session) {
          auto evb = session->getEventBase();
          if (!evb || !evb->isInEventBaseThread()) {
            session->attachThreadLocals(
                eventBase, ...);
            auto cm = pool_->getTLUpstreamConnManager(eventBase);
            if (cm) {
              cm->addConnection(session, true);
            }
          }
        }
      };
      return std::move(future)
          .via(eventBase)
          .thenValue(func);

from proxygen.

mikekliger avatar mikekliger commented on May 25, 2024

I see! thanks. If i acquire a session via HTTP Connector Callback, and call putSession() to move it into my pool, does the pool override the previously set idleTimeout as soon as the session is put into the pool (Which would come from the wangle::ConnectionManager)

from proxygen.

afrind avatar afrind commented on May 25, 2024

The ConnectionManager controls the idle timeout (when the session has no open transactions). But if you set a transaction timeout on the session at creation time, that should stick when adding to a different CM.

from proxygen.

mikekliger avatar mikekliger commented on May 25, 2024

Thank you that is very helpful. I am still running into a memory issue in unit testing, but i believe it may be an issue in how we are managing our evb/threads.

On issue 314 you mention that thread transferring can be a huge memory win from server POV, , do you observe the same magnitude of effect on client side?

from proxygen.

afrind avatar afrind commented on May 25, 2024

For us the memory win on the "client" side (eg: the upstream half of the proxy) is the significant bit. The total memory savings should be roughly the same on both sides, but there are fewer proxies than servers and they tend to be more memory constrained.

from proxygen.

mikekliger avatar mikekliger commented on May 25, 2024

Thanks so much, thats great to hear.

I have one last question before closing: between calling attachThreadLocals() and getIdleSession(), where does the HTTPConnector come into play? Is there a relationship between the session's connection that is being transferred, and its HTTPConnector that is used to establish that connection?

I know in connectionManager I have access to a callback called onConnectionRemoved(const wangle::ManagedConnection* c). Once I have a connection/session established, what role does the HttpConnector play? If i transfer a connection/session I would think I need to either transfer this HttpConnector along with them, or return it to the pool of connectors we use along with our connection manager (since this is how we obtain new sessions/connections).

from proxygen.

mikekliger avatar mikekliger commented on May 25, 2024

So thread A gets session from Thread B. Thread B removes connection from Thread B's connection manager. From thread B perspective, I would need to free up that HTTP connector. But unless I am missing something, onConnectionRemoved() does not give me that access

from proxygen.

mikekliger avatar mikekliger commented on May 25, 2024

Ah I made a mistake. I suppose the connector is irrelevant and it will free itself upon connectSuccess or Error. i will close the issue today.

from proxygen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.