Comments (4)
Hi @dcy. We never had the need for that, but we'll be happy to evaluate a PR with those changes if you send one our way. If you're about to implement it, I recommend you tu use @jaynel's epocxy.
from apns4erl.
It's not quite so simple as just pooling, since apns_connection is a gen_server and internally it uses a bounded queue implemented as a gen_server. There are two levels of serialization that you need to think through. Most of the work is actually formatting, with a final send on an SSL socket happening at the end of the apns_connection logic. To get any efficiency you would want to rethink that serial pipeline of events. If you took another approach, though, you would still not want multiple processes writing to the same socket directly to avoid interleaving data, unless you can ensure that atomic packets are sent completely.
from apns4erl.
SSL itself has some serialization per connection as well, so there may be no gain on sending concurrently unless you have multiple connections. I say this ambiguously because there have been large changes from 17 -> 19 and it depends on the version of erlang you are running. I would expect if you overload APNS it will just disconnect you, so spewing at it probably isn't a good thing and handling 100s of connections for errors when it isn't performing well might be a mess in the code. I would look at optimizing the formatting concurrency before tackling any sending issues. Once you have a good binary packet, sending should be relatively quick and you should probably detect and limit the pace at which you send data to the external service. Spread across machines and make each machine nice to avoid taking out your partners' services.
from apns4erl.
@jaynel I mean there are multiple processes, every process have one connection.
When apns:send_message
use erlang:phash2(DeviceToken, N)
to select which process to send this message.
I don't know if this way is good.
from apns4erl.
Related Issues (20)
- adding coverage in Travis
- Increase test coverage
- Connections using Provider Auth Token HOT 1
- how to send mutiple token to apns in one time? HOT 4
- Rebar compile issues when included in other projects HOT 1
- version bump to 2.3.1
- New 2.4.0 release HOT 2
- apns:connect error HOT 3
- Maintenance-related issues HOT 9
- Move from Travis CI to GitHub Actions? HOT 2
- Release request HOT 2
- CRASH gun_http2:parse in server logs HOT 26
- src/apns_connection.erl:22: Warning: undefined callback function terminate/3 (behaviour 'gen_statem') HOT 12
- Erlang (Not apns4erl) Question HOT 3
- With gun-2.0.0-rc.1, apns reconnections are much more frequent than with gun-1.3.3 HOT 3
- timeout key is expected but its presence is not verified in apns_connection:init/1
- Improvements from Akick HOT 4
- Function not exported {string,lowercase,1} HOT 3
- apns crashes with {case_clause,{error,{closed,"The connection was lost."}}
- push current master to hex.pm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apns4erl.