Git Product home page Git Product logo

Comments (4)

mcbirse avatar mcbirse commented on July 18, 2024 1

Hi @KevM - setting PW_POOL_MAXSIZE=1 limits the connection pool size for HTTP persistent connections / re-use to 1. The thinking there "should only be one" connection is a misunderstanding of how this works...

It's due to the fact the pyPowerwall proxy is a multi-threaded HTTP server. For every API request sent by telegraf, a new connection could be opened to the gateway, and telegraf sends multiple requests simultaneously so you will end up with multiple connections due to the multi-threaded nature of the application.

Limiting the pool size to one just means the pool size won't be big enough to serve all the API requests, and you will see pool full warnings, connections discarded and re-opened to serve the request. Setting PW_POOL_MAXSIZE=0 will disable connection pooling and persistent connections, which means a new request to the gateway is opened/closed for every single API request from telegraf (slower, probably adds additional load to the gateway, and guaranteed to not see those warnings if it bothers you).

Persistent connections with the use of a connection pool was implemented to reduce load on the gateway. At least then generally, only e.g. 15x connections would be opened to the gateway. If there were more than 15 simultaneous API requests you will still see pool full warnings though.

There is background on this in issue #20 where I did an analysis of the connection use and benefit of the persistent connections / pool, implemented in PR #21

I'm using the default pool size of 15 and never see any warnings or have performance / drop out issues at all (note - direct ethernet connection to the gateway helps a lot too).

If you really only wanted a single connection from pyPowerwall being used for all API requests to the gateway, then we would need to implement a similar connection use setup that was done for the Cloud mode. Because pyPowerwall is multi-threaded, then this would involve adding locking around API requests to the proxy, so only a single thread would send requests to the gateway - refer #59 (comment)

It's not a bad idea to implement this to be honest... especially if we start seeing issues with the gateway not responding well to having multiple HTTP sessions opened simultaneously (although, I have not seen issues with this so far). It was necessary with the Cloud mode setup due to the cloud limiting connections and often responding with HTTPError: 429 Client Error: Too Many Requests.

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024

Excellent synopsis @mcbirse... 🙏

from pypowerwall.

KevM avatar KevM commented on July 18, 2024

I've moved away from using PyPowerwall because of this issue. After using a raw connection to the gateway I do not run into any login reconnect issues.

That said I also started using the FleetAPI directly for my needs. The historic precision is limited to 5 minute intervals but this is good enough for my needs. 🤷🏼

from pypowerwall.

jasonacox avatar jasonacox commented on July 18, 2024

Thanks for the follow up @KevM .

from pypowerwall.

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.