B4J Question App limits

JackKirk

Well-Known Member
Licensed User
Longtime User
I'm after any guidance I can get on the following.

I have 2 B4J apps that run in parallel in AWS EC2 instance/s (essentially virtual PC/s running Windows 10).

App#1 is basically just an FTP server based on:

https://www.b4x.com/android/forum/t...plemented-with-socket-and-asyncstreams.74320/

with some minor mods, that accepts 4-6MByte jpgs from remote 6megapixel IP cameras and drops them in a buffer area on the AWS EC2 instance disk.

Going over this app it appears to be quite open ended (for want of a better term) - there do not appear to be any obvious explicit limits.

The IP cameras are pretty high tech with all sorts of internal buffering capabilities etc.

This app could be serving 16-20 IP cameras simultaneously each running 0.5-1 frames/sec at peak - a theoretical absolute peak load of about 1,200 MBits/sec. Generally all cameras will not be at peak output at the same time and I'm currently guessing a real peak of no more than 300-600 MBits/sec.

The networking guru tells me we are going to be using bonded internet to get some (as yet to be determined) multiple of 100 MBits/sec from the camera site and will be relying on the camera buffering to smooth the load.

But it could mean App#1 is simultaneously digesting 20 x 6MByte = 120MBytes of data - will this hit any walls?

App#2 is a processor - it takes files from the buffer area and FIFO processes them (moves them to AWS S3 buckets, creates thumbnails, determine watermark locations etc).

Using the new Wait For functionality each instance can handle a user defined number of files simultaneously.

During processing each file is converted to a bitmap - so a memory requirement of at least 6megapixel x 4 bytes/pixel = 24MBytes per file is required at some point in processing.

If 20 files were being processed simultaneously this suggests a possible peak memory requirement of 480MBytes per app instance - will this hit any walls?

App#2 has been written so that it can tolerate multiple instances of itself running in parallel, "feeding" on the common buffer area.

=========================================

We are getting close to the start of the implementation of this and I would dearly love any useful suggestions, war stories etc to give me forewarning of any possible obstacles - be it B4J, java, Windows 10, AWS EC2, AWS bandwidth etc.

Thanks in anticipation...
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I guess that both apps are not based on jServer, right?
With the exception of jServer solutions, your code runs on the main thread. This means that you should be careful not to do too much synchronous work as it will occupy the main thread and block all tasks.

You will get the best performance if you implemented your solution as a http server with jServer. This means that you will send the images as http requests instead of FTP.
 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel, thanks for the quick response.

I guess that both apps are not based on jServer, right?
App#1 is essentially using the FTP server code from the URL I pointed to.
App#2 does not use FTP - it is my own code using HTTP sitting on HttpJob.bas/HttpUtils2Service.bas and the OkHttp library.

With the exception of jServer solutions, your code runs on the main thread. This means that you should be careful not to do too much synchronous work as it will occupy the main thread and block all tasks.
I'm digging into my dusty past recollections but I seem to recall running multiple tasks on different threads of a dual quad core Wintel box - I assume I will be able to do this with java?

You will get the best performance if you implemented your solution as a http server with jServer. This means that you will send the images as http requests instead of FTP.
OK, I'm happy to seriously look at this - this would mean the IP cameras would have to do HTTP correct?

Appreciate your help...
 
Last edited:
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

this would mean the IP cameras would have to do HTTP correct?
Sorry - pretty dopey question in hindsight.

I will have to play around some more with the cameras, but I suspect normal mode of operation is to use http via prebuilt UI's to set cameras up then use ftp to basically let the camera control uploads.

I'm digging into my dusty past recollections but I seem to recall running multiple tasks on different threads of a dual quad core Wintel box - I assume I will be able to do this with java?
I dug and remembered Process Lasso which was a great bit of kit. I installed the 30 day trial of this on my AWS EC2 instance plus VisualVM. I upped the EC2 to a dual-core and played around - without doing any core affinity assignments it looks like App#1 and App#2 loads are automatically spread out over both cores - is this what you would expect?

Thanks again...

 
Upvote 0

JackKirk

Well-Known Member
Licensed User
Longtime User
Erel,

Do you mean to ask whether it is possible to do it with B4J?
I'm interested in ensuring the multiple B4J apps get their CPU load as evenly spread as possible across all cores.

I think I am seeing this happening without any need to force the tasks onto specific cores - and think this is what you are confirming in the previous post.

If so it means my tuning exercise gets reduced to not much more than adjusting the EC2 size as necessary.

BTW for any one interested I re/discovered Process Explorer which is a sufficient free substitute for Process Lasso (which costs $ on any AWS EC2 Windows instance because they are all Server editions).
 
Upvote 0
Top