IOS push (difference between javapns package and notnoop package)

Source: Internet
Author: User

Java is used for IOS push. There are two famous open-source jar packages: javapns and notnoop.
For javapns, we have previously introduced Memory leakage. This problem is serious, as shown in:
1. The pushed consumer y will be saved and not recycled.
2. By default, the corresponding Vertor Stores Policy. This array is automatically resized, and memory increases greatly in large batches.
3. to avoid the continuous failure between the socket and the Apple Server during the sending process, the push sent by the SOCKET fails. You can configure a socket to send a certain number of pushes and then restart the link, avoid repeated failures;
In addition, the producer y that has been sent Will be poll before restarting the socket. If the corresponding producer y fails to be pushed, resend the service and process javapns.
The above problems can be fixed by modifying the source code. The main solution is memory leakage, which can be recovered in advance. In addition, the feedback service is timely, and the issue of push resending is not serious.
The service modified based on javapns has been running normally and has been pushed for millions every day. It has not encountered any problems after several months of stable operation.
However, there are still a large number of resources not recycled in the jmap process. In addition, full gc blocking has recently occurred, resulting in restart events. (Another reason may be that all nodes are pushed to a foreign machine, and the memory is very low, only 512 M -.-)
For this evaluation, I generally know that when there are many pushes, there will be a large amount of vector, automatic resizing, and then the corresponding space in the old generation and sur will be filled up, so full gc has no space, and thus the service goes DOWN. In addition, the javapns code is not very comfortable even after it is changed.
In the above context, let's talk about notnoop!
The push service was extended based on notnoop years ago. Because the upper-layer interface is well encapsulated, you only need to implement the PUSH Service on the existing interface of notnoop, then, you can choose to use notnoop for push through preparation.
1. the notnoop package Code results are clear, mainly com. notnoop. apns. the ApnsServiceBuilder class is used to control the creation of the push Object pool and the com. notnoop. apns. internal. apnsConnectionImpl controls the sending of specific push messages. The packages include com. notnoop. apns and com. notnoop. apns. internal.
Structure. The corresponding unit tests are also comprehensive.
2. notnoop constructs a thread pool object (which can also be a single thread) for communicating with apple and pushing.
3. The notnoop push implementation supports queue-based processing, or you can set a scheduled task to process the push in the queue in batches for a period of time. The first method is generally used.
4. notnoop sets a pools thread object pool through the queue and processes all the pushes asynchronously.
5. notnoop only creates the corresponding socket when it is sent for the first time (of course, after the socket is null or isclosed, it will be reconnected ). then there is a separate thread to monitor the InputStream stream of the socket object, to handle the corresponding sending failure of yycation, for the failure of Notifycation will exist in a queue, the system resends the failed notifications. The length of the error queue should be considered here.

6. the same is true for notnoop and javapns. If the producer ycation fails to be sent, the producer ycation will be resending. Of course, the producer class will be failed. If the producer class is I/O exception, the producer will be discarded three times before it is successfully resending, in the middle, WAIT will be tried for a period of time. If the error code returned by Apple fails, it will be re-sent.

The difference between notnoop and javapns lies in the handling of failure ipvy,

When javapns is re-connected, it traverses all failed ipvy in a centralized manner and then processes it.
Notnoop enables a monitor process to process the processed worker y in real time.
The above two mechanisms make the monitor method more reasonable.
In terms of code scenarios and complete unit tests, notnoop can have a big like. For memory overhead, the following is what jmap sees
Num # instances # bytes class name
----------------------------------------------
1: 104004 21613440 [C
2: 36928 8768280 [B
3: 14924 7057840 [I
4: 30776 4193072
5: 30776 4132128
6: 2618 2919376
7: 45554 2460160

Satisfactory performance.
The above are some examples of good intentions, and I hope to help you.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.