Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 8 Jahren, 2 Monaten
Letzter Beitrag:
vor 7 Jahren, 11 Monaten
Beteiligte Autoren:
Robin Lane, Abl, "Albert P.".pcs.crosspost, Robin Lane.pcs.crosspost, Arie

Where do I go from here - advice seeked please...

Startbeitrag von Robin Lane.pcs.crosspost am 04.09.2009 07:35

I am looking for advice please from more experienced programmers on how to proceed

I have written a WinDev application which is on a dedicated server. In simple terms, this application receives data on several sockets multiple times per second. This data is validated, and then saved to a HF database.

I have now been given the job of allowing an infinite number of anonymous clients to have access to this data “Live”, ie second by second as my WinDev application receives it. They are to connect via sockets, and after some initialisation information has been sent, the live streaming of data is to begin.

My question for you all is what is the best / most efficient method of achieving this??

1 Do I write a new WinDev / WebDev application which will stream the data out to the clients? If so how do I share the one string of data between multiple threads every second?
2 Would a web service be a better method of achieving this? Can you cache data in a WD web service so as to minimise the load on the HF database??


Any comments / new ideas would be very gratefully received as I’m a little bit stuck as to the best method to go from here.

Many thanks.


Message forwarded from pcsoft.us.windev

Antworten:

Hello Robert,

Firts question is , can we use the data from the hf database or is live real live data ?
If you want to use the data from the hf database, i would set up a HFCS then
build an application where the user on connects (socket) use for every socket an new thread.

When you use one application for recieve and send your performance can be very low.
If you use 2 applications with HFCS you can even use three different machine's when needed

Succes Ab





von Abl - am 07.09.2009 07:39
Hi Ab,

Yes I think I will go down the HFCS route, and write a new application to send the data out by using threads. I have one further question about this ...

Is there a method of sharing data between threads??

What I mean is for the main thread to read from the HFCS, and distribute the result to the threads. This would mean that there would only be one "read" of the database which I imagine would be faster than each thread having to read from the database.

How do I let the individual threads get the data the need to send?? What is the best way??

Thank you for your assistance.

Robin.

von Robin Lane - am 08.09.2009 08:42
Hi Robin,

I would use a main thread to look is there data and look what other threads there are
With thread sendmessage you can send a trigger to the sub threads that there is data to send.

You can use a global to hold the sending data, but when you do so every thread has to wait for the last thread has send his data, i meant not every socket is at the same speed.

I use a in my connections most of the time the following construction :

One application to put everyting in a HF (just like your application)

To send out i use per client a HFCS that contains the last send messageid for that client
When there is a new message the sending thread for that client is trying sending it out after he reads it in the hf

So when one client is off everything is going in a kind of queu for only that client
And when it comes back everything is send.

Now as for the performance because of the use of HFCS there is always a part of the data in the memory from the dataserver this is very quick and every thread uses another read thread to the hfcs

I have an application with a build in heartbeat that allows on every 10seconds only 50 ms difference. This never gives a problem only when the network is slow (or san but this is also a network connection) so i think i would use the last contruction :rp:

Ab




von Abl - am 08.09.2009 11:46
Hi Ab,

Thank you for your advice.

I will give it a go the way you suggest.

Many thanks again

Robin


von Robin Lane - am 11.09.2009 06:53
Hello all,

I am back to this problem after several months.

I am still struggling to understand the best method of allowing multiple threads (there could be hundreds of them) access to around 200 bytes of data every second. The data is written to an HF database every second by another application, and I am about to start writing a new project which will transmit the data to the clients via threads & sockets.

There are two main options as I see it.
1) each connection performs its own read of the database
2) one read is performed by a thread, & this data is then ‘shared’ to each of the client threads.

I assume that option 1 would be too slow – or am I wrong here??

Option 2 is the one I am stuck with. Would it work if I store the data to be transmitted in a global variable and then use the ThreadSendSignal command to all of the client threads. They could then read the data from the global by using a procedure protected with a Semaphore or CriticalSection. How many ‘reads’ of the data from the global variable would you expect to be managed in a second?

Or am I completely barking up the wrong tree here?

Thanks in advance for your assistance.

Robin.


von Robin Lane - am 30.11.2009 17:43
Robin,
Option 1 would be too slow. I would go for option 2. I'm using this in one of my apps and it's working. I don't have that many threads though (just a few simultaneously), so I can't tell you about speed, but that's faster than option 1 for sure.

There's also a 3th option. Use the HFCS as a message-server, by using the HSendMessageToClient() function. Your "other" application can save the data AND send it as a string to all connected users this way. Again: I'm using this in a small-number-of-client situation to sync agenda-items and some status-info. No problems reported over more than a year now. But with your amount of threads, I again can't tell. You have to try it yourself.


von Arie - am 30.11.2009 19:54

Re: Re: Where do I go from here - advice seeked please...


"Robin Lane" a écrit dans le message de news:
105592009113019000407.41929@news.pcsoft.fr...
>
>
> Hello all,
> I am back to this problem after several months.
> I am still struggling to understand the best method of allowing multiple
> threads (there could be hundreds of them) access to around 200 bytes of
> data every second. The data is written to an HF database every second by
> another application, and I am about to start writing a new project which
> will transmit the data to the clients via threads & sockets.
> There are two main options as I see it.
> 1) each connection performs its own read of the database
> 2) one read is performed by a thread, & this data is then
> ‘shared’ to each of the client threads.
> I assume that option 1 would be too slow – or am I wrong here??
> Option 2 is the one I am stuck with. Would it work if I store the data to
> be transmitted in a global variable and then use the ThreadSendSignal
> command to all of the client threads. They could then read the data from
> the global by using a procedure protected with a Semaphore or
> CriticalSection. How many ‘reads’ of the data from the global
> variable would you expect to be managed in a second?
> Or am I completely barking up the wrong tree here?
> Thanks in advance for your assistance.
> Robin.
>
>


Hi,

Just one question : Are the data to be send the same for all clients ? If
the answer is yes, then there is no need for each threads to acces the
database.

I made a similar application for our own use : to connect to our phone
center (PABX) to analyse incoming and outgoing phone call and to store
information about phone call (start, end, customer name, ...) into a
database to make statistics.

I must then send to each computer the status of each phone of the company,
in use, free or don't disturb as we don't have this information directly on
our phones. This part of the job is done using thread and socket and the
clients application are not linked to the database. All informations are
gathered by the server application (list of all the phone call of the day,
list of all the phone numbers, ...) The server application read the database
and send data to the client by socket.

We don't have hundred of customers (anyways we are limited by the speed of
the phone center - RS232 at 9600b/s) but it's work quite well.

Albert P.


Message forwarded from pcsoft.us.windev

von "Albert P.".pcs.crosspost - am 01.12.2009 08:47
Thank you Arie & Albert for your suggestions

I have decided to try my option 2 as outlined above. I will use a ThreadSendSignal command to each of my client threads in turn, as this will allow me to keep a count of how many clients I can send data to each second.

It will be interesting to find out just what the number is...

Thanks again

Robin.



von Robin Lane - am 02.12.2009 15:26
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.