Best way to call multiple timeseries #365
-
When making multiple calls to get time series are we better of:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
High-level, short answer is that generally it is best to re-use existing connection or sessions, because construction of those takes time and resources. Connections and sessionsPlease note I distinguish between connections and sessions within connection. Connection is a gRPC channel/connection to Mesh server, and session is a temporary workspace used to work with Mesh, see: https://volue-public.github.io/energy-mesh-python/mesh_session.html. To create or use a session you first need to have an open connection. So having less connections and sessions is generally better. Another thing is that it is better to close a session if it is not actively used for longer periods of time. Active sessions consume resources (RAM, CPU) on the server side. If a session is making changes to Mesh, other sessions are notified about those changes and updated. The more active sessions we’ve got the more time and resources this requires. So generally if you need to write/read some data to/from Mesh occasionally or on regular, but longer intervals (e.g. 1 hour) and the operations itself are short it is better to open a connection and create new session only for the operations with Mesh and close them right after. On the other hand if you need Mesh continuously it is better to preserve the connection and sessions whenever possible. Performance best practice - Async APIYet another topic is async API. Depending on your workload you may gain significant performance boost by using Mesh Python SDK async API. It enables you to do processing of data or other operation while waiting asynchronously for Mesh to respond to your next request (e.g.: reading some time series). See example: https://github.com/Volue-Public/energy-mesh-python/blob/master/src/volue/mesh/examples/read_and_process_timeseries_async.py Mesh server - handling requestsCurrently Mesh server is handling Python SDK/gRPC requests sequentially. So you wouldn't gain anything by sending multiple requests in parallel. |
Beta Was this translation helpful? Give feedback.
-
@marthaag please let me know if that answers your question. If you need more details please provide more information on your application and workload it is supposed to handle. |
Beta Was this translation helpful? Give feedback.
-
Additionally, I want to stress that currently Mesh server is handling Python SDK/gRPC requests sequentially. So you wouldn't gain anything by sending multiple read requests in parallel. |
Beta Was this translation helpful? Give feedback.
High-level, short answer is that generally it is best to re-use existing connection or sessions, because construction of those takes time and resources.
Connections and sessions
Please note I distinguish between connections and sessions within connection. Connection is a gRPC channel/connection to Mesh server, and session is a temporary workspace used to work with Mesh, see: https://volue-public.github.io/energy-mesh-python/mesh_session.html. To create or use a session you first need to have an open connection.
So having less connections and sessions is generally better.
Another thing is that it is better to close a session if it is not actively used for longer periods of time. Active ses…