Code Monkey home page Code Monkey logo

Comments (15)

jchambers avatar jchambers commented on May 23, 2024

Can you provide any additional details? How many threads are in your event loop group (if you've customized it), and how many concurrent connections are you using? What was the reason for the rejection? I'm most troubled by this (from your mailing list post):

Seems that pushmanager won't work after error occurred.

Can you be more specific as to what seems to be going wrong? Does it simply stop taking notifications from the public queue? Is there anything in the log output after the error?

Thanks!

from pushy.

 avatar commented on May 23, 2024

I've not customized the number of threads and there is only one concurrent connection to apns.
The reason for the rejection was an invalid token.
I get the apnsConnection error three times, no further log output.

Yes, I think (could not test in particular) that no further notifications are taken from the queue, because no device has received one of the missing notifs.

I'll try to give you some more details tomorrow.
Thank you for your updates on #76

from pushy.

jchambers avatar jchambers commented on May 23, 2024

no further notifications are taken from the queue, because no device has received one of the missing notifs.

I don't mean to be difficult, but could you clarify what you mean by "missing notifications?" I think what's happening here is something like this:

  1. Assume a sent notification buffer capacity of 100.
  2. You send 1,000 notifications.
  3. After all 1,000 notifications are sent, the gateway rejects the very first notification.
  4. 900 notifications are lost because they have already been pushed out of the sent notification buffer. The 100 still in the buffer get re-enqueued.

@fkoebel please let me know if the above could plausibly explain the problem you're seeing. Regardless, this is obviously a serious problem because we're losing notifications. That said, our options are limited because the APNs gateway never acknowledges successful notifications. Our choices are:

  1. Just pick a larger size for the sent notification buffer. This reduces the chances of overrunning the buffer, but at the cost of more memory (and doesn't guarantee that we'll never overrun). This is mostly what we're doing now, although #76 will make it easier to change the buffer size.
  2. "Flush" connections by shutting them down with a known-bad notification whenever their sent notification buffer becomes full. This strikes me as reeeeeally inefficient (and may even be viewed as a DoS attack in high-throughput situations), but does guarantee that we'll never lose notifications due to buffer overruns.

One of the other things we're doing in #76 is adding better logging for this case. I'm curious as to how badly we're overrunning the buffer, and that logging will certainly help us understand the issue more clearly (though having somebody lose notifications in production is, obviously, not the way we'd like to get that information).

from pushy.

 avatar commented on May 23, 2024

Yes, that's exactly what I think too.

Just for my comprehension:

  1. Assume buffer size of 100
  2. Sending the first 100 notifications (assuming sequence number 40 for an invalid notif)
  3. Notification buffer gets emptied, because there is obviously no rejection (or did you immediately notice a rejected notif?)
  4. Another 100 notifications will be taken from the queue to the buffer
  5. Rejected notifiation registered (number 40), searching for sequence number 40 in the buffer, but this notif is not anymore in the buffer -> the error occurred.

Am I right?

from pushy.

jchambers avatar jchambers commented on May 23, 2024

You're mostly right. The twist is that we don't completely empty the buffer when it gets full. If we fill the buffer (still assuming a capacity of 100 notifications), then send one more notification, the oldest notification will get bumped from the buffer and the new one will be added. In other words, the buffer will contain notifications 2 through 101.

But otherwise, yes, what you wrote is accurate.

from pushy.

 avatar commented on May 23, 2024

Thank you for your reply making the error more clearly.
I'll try different buffer sizes and will report which size works for me to prevent the error.

from pushy.

jchambers avatar jchambers commented on May 23, 2024

I'll try different buffer sizes and will report which size works for me to prevent the error.

Excellent. Thanks kindly.

I know I mentioned on the mailing list that you could edit the hard-coded buffer size in ApnsConnection. If you'll be experimenting with buffer sizes, though, I'd strongly encourage you to use the approach in #76 both for ease of use and for better logging in case something continues to go wrong (and we'll hope it doesn't).

from pushy.

 avatar commented on May 23, 2024

Yes, I forgot to mention that I actually work on configurable_sent_buffer_size branch

from pushy.

jchambers avatar jchambers commented on May 23, 2024

For what it's worth, we just merged #76 into master, so please feel free to use that, if you'd like.

from pushy.

jchambers avatar jchambers commented on May 23, 2024

@fkoebel Any news on your end? Have you had luck with the changes in #76?

from pushy.

jchambers avatar jchambers commented on May 23, 2024

I think #76 offers half of the solution here, and #118 offers the rest. The idea is that you can (after #118 gets merged) set your own sent notification buffer size, and also configure connections to close after a set number of send attempts. As long as the number of send attempts is less than or equal to the sent notification buffer size, we'll never lose notifications to buffer overruns. That said, there are still other ways to lose notifications (i.e. non-graceful shutdowns).

from pushy.

marcomorain avatar marcomorain commented on May 23, 2024

We've hit this this week at Swrve: https://app.getsentry.com/team-swrve/jvm-production/group/22614269/ (I've made the Sentry issue public)

from pushy.

jchambers avatar jchambers commented on May 23, 2024

We've hit this this week at Swrve.

Acknowledged. Looking forward to getting the next version of Pushy out the door so people can use #118 if they need it. I'm afraid it's the best workaround we can offer given the limitations of APNs.

from pushy.

marcomorain avatar marcomorain commented on May 23, 2024

Oops, I've just read back over my comment above it sounds like I'm complaining! I just wanted to add more data to help you guys understand the issue 👍

from pushy.

jchambers avatar jchambers commented on May 23, 2024

I just wanted to add more data to help you guys understand the issue

No worries! That's definitely the spirit in which it was received. Sorry if I came across as defensive!

from pushy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.