Android Question Push notification and NGINX issues

Christian García S.

Active Member
Licensed User
Hello,

I have an app that is currently subscribed by about 70k people on android, when I send a PUSH notification through firebase the application in the fm_MessageArrived event calls a web service and updates certain things in the database through an NGINX server.

The problem happened when I push the general TOPIC, the server did not support so many requests at the same time and I got a "Too many open files" error.

Tonight I'm going to change the settings so that NGINX allows more files open at the same time, and some other limit settings in the operating system.

But is this the correct way to do things ?? Or there is some other method that you can recommend, I know that you can also send PUSH to groups but it can only be done in groups of 1000 and it would be very tedious to go through the entire database to group people.

I was thinking of making a connection using MQTT, but certain ISP providers at home or in shopping blocks access to TCP ports so I would not have all the information.

Can you recommend me any ideas?

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
Why you need to open a file at all?
It should be possible with a Database and ONE Databaseconenction in JRDC2.
 
Upvote 0

Christian García S.

Active Member
Licensed User
Hello,

Reviewing the information nginx opens files for each request it receives, that is why it gets an error for many open files, it is an operating system limitation, I had to increase that number of open files at the operating system level.

I have done a push today and the nginx error does not come out, now I have other errors that the operating system has another limitation of many open tcp requests, and the connections to mysql were not established.

I'm going to keep trying, I think that with another web server like jRDC2 I can have the same results, I have to do some tuning.

Do you think that architecture is correct? that is, send a push and for each push make a request to the web server to register who received that push?

Someone comes up more optimal way that is not necessarily in real time to save who received the PUSH.

Thanks
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't assume that you can make a network request when a notification is received. In iOS it is not possible at all. In Android it will also not always work.

Making 70k connections to the server at the same time is the same as making a DDOS attack on your server.
I would say that you should add a random interval to spread the connections, however a better idea will be to make a request when the user opens your app.
 
Upvote 0

Christian García S.

Active Member
Licensed User
Thanks @Erel,

I increased some limits on SO and yesterday I received 35k (before 20k). I still get some issues in server but it is minor.

I explain a bit how I am doing, I send through Firebase when the device receives the message the event fm_MessageArrived make a query to the database, the campaign data and the previous image that must be loaded in the notification, too inserts a record in the database that customers receives notifications.

I was thinking of changing the body of the message to receive all the information from the PUSH, and avoid many requests to the server, in addition to registering that that client received the message calling a URL but this url is connected to a RabbitMQ queue, which will prevent connections in the database.

Do you think if I create random numbers from 1 to 20, and with this number I put in a delay before make a request, that would reduce the concurrent calls? 20 seconds is not long for something to happen to the app and it crashes? or do you think I should put a lower range.

Thanks for your help
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Do you think if I create random numbers from 1 to 20, and with this number I put in a delay before make a request, that would reduce the concurrent calls? 20 seconds is not long for something to happen to the app and it crashes? or do you think I should put a lower range.
Adding a delay will help. The problem is that Android might kill the app before the request completes. Make sure to call StopAutomaticForeground after the request completes, and not before it.
 
Upvote 0
Top