Server sessions [message #1758831] |
Mon, 03 April 2017 11:01  |
Eclipse User |
|
|
|
I have read that server FBs are only able to handle one client connection at a time, requiring the client to disconnect before another one can connect. I imagine this has something to do with session handling.
Is there a place where I can found more information about this topic?
Is there any design concept behind this feature? Or being able to handle multiple clients has just not been implemented?
|
|
|
|
|
|
|
|
|
|
|
Re: Server sessions [message #1759085 is a reply to message #1759068] |
Thu, 06 April 2017 02:58   |
Eclipse User |
|
|
|
Alois Zoitl wrote on Wed, 05 April 2017 19:39I think there is a slight misunderstanding. with RSP the application would inform the communication layer that the last message recieved was processed by the application and if there are more messages pending the next message could be applied to the outputs and a new IND could be sent. Currently this is not forseen in the desing. In CComFB::receiveData all pending messages are handled at once and in principle the last message is applied to the outputs. Therefore a major redesign would be needed.
I understood it right, probably it was a poor explanation from my part. I was trying to say that the server would have to RSP either positive or negative every IND it receives so that a new IND from the queue could be processed. And then I tried to say what you just said, that right now every IND in the queue is being processed and the highest error code is being returned, which is actually a bit strange.
Alois Zoitl wrote on Wed, 05 April 2017 19:39In principle we are handling already in a multi-threaded way. At least in a limited way. We have the thread with the select loop which is taking tha packet and will acitvate the FB in the thread of the resource the FB is loacted in. In this thread the messages is processed by the application and the answer is returned.
You are using 2 threads: one for feeding the queue and one for extracting from it. Right? I was talking about multi-threading extraction, so that a higher amount of events could be handed. This is a quite common approach when a single server has to serve multiple clients and the operation it does requires some computing time. This way there would be a single thread feeding the queue with every request it receives and a pool of workers handling them. This is probably not taken into account in IEC 61499, it just came to my mind when we talked about multi-client servers. This would require some not trivial things like: thread-safe queues, different FB bound to the same queue, etc.
And we could go even further, if we are able to monitor the size of this queue, we could make a FB application that deploys or deletes all the FBs required to handle each service, thus having a dynamic size of this worker pool. Was my explanation clear?
Alois Zoitl wrote on Wed, 05 April 2017 19:39In OCP UA we are currently only supporting the UPC UA server side. Here we you are able to use PUBLSIH/SUSBRIBE to add write/read variables to the OPC UA information model and to use Server to over Methods which can be called by a client.
By information model you mean the Address Space? OPC-UA is planning to add or has recently added pub/sub paradigm support, so using the PUBLISH and SUBSCRIBE FBs to modify the Adress Space may require a different 4diac's layer to implement the pub/sub paradigm or modify the behaviour you mentioned.
|
|
|
Re: Server sessions [message #1759140 is a reply to message #1759085] |
Thu, 06 April 2017 08:18   |
Eclipse User |
|
|
|
Adrian Orive wrote on Thu, 06 April 2017 06:58
I understood it right, probably it was a poor explanation from my part. I was trying to say that the server would have to RSP either positive or negative every IND it receives so that a new IND from the queue could be processed. And then I tried to say what you just said, that right now every IND in the queue is being processed and the highest error code is being returned, which is actually a bit strange.
Youe are right and that is the reason for my proposal. But it would require some significant rework of all the layers.
Adrian Orive wrote on Thu, 06 April 2017 06:58
You are using 2 threads: one for feeding the queue and one for extracting from it. Right? I was talking about multi-threading extraction, so that a higher amount of events could be handed. This is a quite common approach when a single server has to serve multiple clients and the operation it does requires some computing time. This way there would be a single thread feeding the queue with every request it receives and a pool of workers handling them. This is probably not taken into account in IEC 61499, it just came to my mind when we talked about multi-client servers. This would require some not trivial things like: thread-safe queues, different FB bound to the same queue, etc.
And we could go even further, if we are able to monitor the size of this queue, we could make a FB application that deploys or deletes all the FBs required to handle each service, thus having a dynamic size of this worker pool. Was my explanation clear?
Yes you made yourself clear. I'm not sure of the current modelling language means of IEC 61499 are apt to that task. But what is definitely a point is that we currently have only one thread which is handling all incoming tCP & UDP messages and forwards the data to x-threads for all resources (and if RT events FBs are involved even more). So the design question would in the end be how to move as much as processing from the receiving thread to the processing thread. But on the other side this requires not only threadsafe queues but also a lot of memory. Which may be a nissue on some devices.
Adrian Orive wrote on Thu, 06 April 2017 06:58By information model you mean the Address Space? OPC-UA is planning to add or has recently added pub/sub paradigm support, so using the PUBLISH and SUBSCRIBE FBs to modify the Adress Space may require a different 4diac's layer to implement the pub/sub paradigm or modify the behaviour you mentioned.
Yes I meant the information model accessible via the address space. OPC Foundation has just recently finally published the first version of the PUB/SUB spec. Currently we don't have an OPC UA stack already implementing this spec available. But when we definitly would also like to support this in 4diac. From a first guess I would say that either it will be a special layer or that the OPC UA layer will get new parameters.
|
|
|
Re: Server sessions [message #1759157 is a reply to message #1759140] |
Thu, 06 April 2017 18:59   |
Eclipse User |
|
|
|
Alois Zoitl wrote on Thu, 06 April 2017 12:18Yes you made yourself clear. I'm not sure of the current modelling language means of IEC 61499 are apt to that task. But what is definitely a point is that we currently have only one thread which is handling all incoming tCP & UDP messages and forwards the data to x-threads for all resources (and if RT events FBs are involved even more). So the design question would in the end be how to move as much as processing from the receiving thread to the processing thread. But on the other side this requires not only threadsafe queues but also a lot of memory. Which may be a nissue on some devices.
To obtain the maximum throughput, the optimal design would be to reduce as much as posible the tasks of the bottle neck part. In this case, as a single thread would be handling every incoming communication as the TCP/UDP layer does right now, the quickest this thread can store the item in a queue and get ready to process another one the more messages that the application would be able to handle.
The processing of each message then could be slower than the speed at which they can get queued, specially if they are input/output bounded such as storing the value in a DB or executing a ramp up start for an actuator:
Imagine we have a device logging into a DB every alarm that occurs in a machine in order to be able to have a historic record of what went wrong. A single SERVER FB should be able to handle it easily as alarms should happen in sporadic situations (hopefully) and if there is a time interval when alarms are happening faster than what we can store them, a backlog will be stored in the queue, as after this rare multiple alarm interval happens there will be time for the single SERVER FB to handle all the enqueued messages.
Now lets say we want to store sensors data at a high frequency instead of alarms. If we start getting a backlog it will never get cleaned up as items will keep getting in until the queue is full and we start loosing data. Lets assume the bottle neck is never the DB, as this would be another problem out of 4diac scope. This is quite common in high throughput distributed DBs where the latency of a single operation is higher than the time required, so a single synchronous worker will not get to maximum thoughput. A monitoring application could be watching the queue size, and in case it gets to certain threshold, duplicate the storing application (SERVER FB and all the others FB required to store data) in order to get rid of the backlog, and maybe keep this duplicated application or just deleting it after a lower threshold is reached again.
With this example I try to demostrate how processing could be increased while the first thread that enqueues the messages can't, so it is the bottle neck, and thus should need the lowest time per operation.
Obviously this will depend on the HW characteristics but this is unavoidable. Bigger devices would be able to serve orders of magnitude more messages than constrained devices, the point is optimizing this bottle neck so that in any case it is working as close to its maximum performance.
Also worth note that my example would require a way for the runtime to monitorize itself, in this case the communication queue size. This is a feature that I think is needed, but it is a whole new topic as if I'm not mistaken, this can't be done right now.
[Updated on: Thu, 06 April 2017 19:04] by Moderator
|
|
|
|
Re: Server sessions [message #1759376 is a reply to message #1759347] |
Tue, 11 April 2017 02:49  |
Eclipse User |
|
|
|
Can I have more than one SUBSCRIBE or SERVER FB giving the same service? For example, if I'm subscribed to a endpoint that sends data every second, and my processing of this data takes one second and a half, could I duplicate the application that handles this subscription sharing a single message queue in order to balance load? That is the question.
|
|
|
Re: Server sessions [message #1759383 is a reply to message #1759376] |
Mon, 10 April 2017 19:22  |
Eclipse User |
|
|
|
You can have several SUBSCRIBE FBs subscribing to the same address. This is not possible for SERVE FBs. At least not for the TCP. However I don't see the bottleneck in this use-case in the communication FBs but in the application. In such cases, I think it would be more appropriate to implement the load balancing on IEC 61499 application level. For example, you could use an E_CTU to count the IND events and based on the count value switch the execution flow with a MUX FB. The data outputs of the SUBSCRIBE or SERVER FB can then be wired in a fan out fashion directly to the processing FBS. FORTE has been designed to make fan outs of data connections very efficient. So that only one connection object is held in memory for all faned out connections.
|
|
|
Powered by
FUDForum. Page generated in 0.04196 seconds