Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Multiple SocketConnections, is it real?

I have an application that uses multiple SocketConnections.It downloads parts of the same file from 10 servers simultaneously (like Flashget). Each SocketConnection uses a separate thread,it requests one part from one server and waits for the answer.

I get following interesting facts. While using 1 thread, sniffer shows that request to server  in real goes away after 2 seconds after flush.
By increasing the threads number to 10, "after the flush" delay is increased in proportion . It turns out that the speed of 1 and 10 threads is the same. That is despite the fact that socketconnection uses 10 threads, it looks like they are working  sequentially ,i mean that, until one thread with socketconnection not receive a response from the server, the second and subsequent can not send a new request.

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Multiple SocketConnections, is it real?

Is this surprising?  Having mutliple threads only increases through put if there is some overlap possible, which I suspect is unlikely to be the case over a wireless (non WiFi) connection. 

New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Re: Multiple SocketConnections, is it real?

This problem occurs with all transports.

Here's an example. My Blackberry can download with WiFi at 5 Mbps. 1 server has upload speed about 128kbit. So when i use one, five ten threads(servers) simultaneously , the total speed is  approximately 128kbit-150kbit.

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Multiple SocketConnections, is it real?

i suspect there is very little you can do, as all networking is handled by a framework which probably does not use multiple threads.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Re: Multiple SocketConnections, is it real?

It would great  to get an official response from the developers of Blackberry OS.

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Multiple SocketConnections, is it real?

Understand. 

 

But I still not convinced that you should see any improvement using multiple threads.  If all the Threads are doing is downloading, why should multiple downloads get better throughput?  If you did, this would suggest that the communication method reserves some bandwidth for second or subsequent connections - and why would it do that? 

 

For me, the only way you will see throughput benefit from multi-threading is when there is overlap of activities using different resources - for example, while you are writing the data to the SD Card from one download thread, then another download thread can be using the network. 

 

And remember that there is only one processor on BB devices, so anything using the processor is blocking everything else. 

 

Just out of interest, what size 'chunks' are you trying to download at a time?

New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Re: Multiple SocketConnections, is it real?

[ Edited ]

Multiple threads  should increase the total download speed, because maximum speed of My phone(with wiffi) is 50 times bigger then upload speed of 1 server. So, according to the logic, it  is clear that it is necessary to use 50 threads to fully load the phone speed. I tried chunks 4,8,16 kbyte.

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Multiple SocketConnections, is it real?

Good point - what phone are you testing on and what downlaod speed are you seeing using WiFi?

New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Re: Multiple SocketConnections, is it real?

BB 9800. Maximum speed is about 128kbit. It is the same as upload speed of one server.

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones

New Developer
9RAY
Posts: 20
Registered: ‎05-18-2012
My Device: 9800

Re: Multiple SocketConnections, is it real?

I tried to remove all file operations and left only network threads. Downloading speed with wifi increased in 10 times, but BIS speed increased only in 2 times(is about upload speed of one server*2). But real download speed with BIS is much bigger(when downloading files from sites).

-------------------------------------------------
Torrent client for blackberry phones
DjVu reader for blackberry phones