Effective design for mobile phone with update

I was introduced to this problem a few days ago. It was required to develop a mobile application that serves sports content for the user (say, football). The application will allow the user to connect to a specific team. Based on the selection of a userโ€™s command, applications only serve the content associated with this command on the user's home screen. Of course, the user has the opportunity to see the content for all teams (via menu options).

Particular attention was paid to the question of how to update the contents on the user's home screen automatically, and also to take into account that the user (or did not subscribe) subscribed to a specific command.

To the last question, I proposed the following 2 solutions:

1) The application can send tiny requests to the server, which will contain only the user ID, the choice of the user command. Based on the choice of the command in the input request, the server will return only the content associated with the command.

2) If the amount of content is less, and the number of individual commands is small, then broadcast all the information and let the application perform the necessary filtering (of course, this is less efficient compared to C # 1).

Share this on the forum to get other possible design decisions. If this is not the right forum, please reply in the comments and I will post to the appropriate forum.

thanks

+5
source share
3 answers

Definitely option 1).

We have developed something similar in another industry where users are interested in receiving information about the states of different resources. The architecture is as follows:

  • The server supports all user subscriptions. What you save: SubscribedUserId , EventType (win, loss, number ofPointsChanged, whatever it happens), deliveryChannel (http notification, email, push notification for mobile phones)
  • Whenever something happens to a resource, we put a message in the queue. The message contains such things as: teamEventIsFor , subscriber server , deliveryChannel , delivery address , etc.
  • Separate Windows services (one that handles all delivery types [email, http, push] or one for each channel) consumes queue messages and delivers the actual content to users. In your case, this will be through push notifications.

Now, bearing in mind that push notifications do not guarantee delivery (although you get a pretty good delivery speed in general), you can also implement some kind of http resource in which the mobile application can interrogate from time to time to check if there are any some news for this particular user (which is optional).

+4
source

Basically, when you want to do an automatic update, you have only two ways:

1: client sending request periodically. This is sufficient if:

  • The refresh interval is not too short.
  • You do not expect your application to be launched for millions of people.
  • Calculation of the result is not too expensive.

This can be implemented with the least use of any query on the server side of the database. Of course, if you need better performance, you may have some intermediate layers.

2: Pushing results from servers: this is a bit more complicated for the architecture, but there are some good points here:

  • You send customers only new data.
  • Performance is best

However, limits are more important:

  • Handling lost connections is a bit more complicated.
  • You need to catch all the events that update the data in order to push your update to customers.

But since there are more than you who need this solution for architectural solutions: here is the one that suits you best at Javaworld:

JMS: Java messaging service, which is a message-oriented middleware (MOM).

JMS is a specification with a different implementation, mannaly I would go for activeMQ, which is Apache. Here's a topic about that: What JMS implementation are you using?

If you are not using JMS / cannot, just remember this: Messare-Oriented-Middleware . Google to help you find what you need.

+4
source

You have a third option:

3) Follow the subscription publishing template.

To implement this, you can use a system such as Amazon Simple Notification Service (SNS) . First you will need to configure the platform application containing your API key (for Android) or the private key and APNS certificate (for iOS).

When a user launches your application for the first time, the application will ask the user to allow access to push notifications, contact your server and send a token (which is used to register the endpoint in the SNS platform application).

This allows you to send push notifications to an application running on a user device (which can be processed silently or displayed as a real-time notification of new data).

Then you can configure themes for each team that this user can choose to subscribe. When a user selects a command, the application sends a request to your server to subscribe to the topic that you forward AWS using your API. If a user wants to unsubscribe from a topic, you redirect this request to AWS again.

This allows you to send updates for each team in the appropriate topic and distribute this information - only for users who subscribe, scale and in real time. Your server will only need to carry the topic once, and AWS will handle the delivery to each user.

Of course, you will need to implement the logic for processing notifications, subscriptions, registrations, etc., but this allows your users to receive updates in real time.

Review your options:

1) The easiest way to implement and possibly necessary for new installations that are not yet registered. You will need this anyway, so I would recommend you implement this method initially. However, your servers will be under a load proportional to the users, so it would be useful to consider option 3) as you scale (and use an HTTP cache such as varnish or squid to minimize computation and database load)

2) It is not necessary to transmit this information to all users, but it effectively publishes, subscribes with one topic (all users). It would be more efficient to only notify users of this.

3) This is the most scalable option and has the added benefit of real-time. You could notify the user of the update, even if they are not using your application at that time. In the publish-subscribe architecture, you can only notify users who are interested in your information, and after the update, you can set a timeout value that prevents the user from updating from your server up to XX times. Thus, if updates are more frequent than your timeout value, users will never need to hit your server.

+1
source

All Articles