Scaling push notifications to millions of devices using notification hubs
-
Upload
cloudbeatsch -
Category
Mobile
-
view
489 -
download
4
description
Transcript of Scaling push notifications to millions of devices using notification hubs
@cloudbeatsch
Beat SchweglerMicrosoft Corporation
Twitter: @cloudbeatschBlog: http://cloudbeatsch.com
scaling push notifications to millions of devices using notification hubs
@cloudbeatsch
push notificationsintegral part of modern applications
@cloudbeatsch
different platforms : gcm - apns - mpnssimilar concepts and architecture
@cloudbeatsch
platformnotification
service
app back-end
app
1
2
3
4retrieve handlestore handle
send notification
@cloudbeatsch
platformnotification
service
app back-end
1
2
3
4
Client Notification
Service
App
retrieve handlestore handlesend notification
@cloudbeatsch
unique token per device and apppersist, refresh and retrieve millions of tokens
challenge - registration management
@cloudbeatsch
~1 millisecond to send an async notification~16 minutes to send 1 million notifications~32 servers to send them within 30 seconds
challenge - time to deliver message
@cloudbeatsch
personalized per user and/or devicelanguage, message format, visualsmetrics (currency, temperature, length …)
challenge - message personalization
@cloudbeatsch
users/apps subscribe to topics only interested in rugby and tennis newsand only when written by Rob, Ben or Paul
challenge - message routing
@cloudbeatsch
notification hubshighly scalable pub/sub based service
@cloudbeatsch
Bing (news, finance, sports, …)
Sochi 2014
preinstalled on windows
millions of devices
millions of notifications/day
minutes to delivery
interest groups(countries, disciplines, athletes)
localized notifications
million devices(iOS, Android, WP)
million notifications
10s
3+ <2
100s
3+ 150+
@cloudbeatsch
platformnotification
service
app back-end
app
1
2
4
5
retrieve handlestore handlesend notification
notification hub
3
@cloudbeatsch
apns
app back-end
Android app
1
2
4
5
notification hub
3
iOS app
gcm
5’
4’
3’
1’
2’
retrieve handlestore handle
send gcm notificationsend apn notification
@cloudbeatsch
Windows 8var channel = await PushNotificationChannelManager.
CreatePushNotificationChannelForApplicationAsync();var hub = new NotificationHub("<hub name>", "<connection str>"); var result = await hub.RegisterNativeAsync(channel.Uri);
iOSdidRegisterForRemoteNotificationsWithDeviceToken:(NSData *) deviceToken { SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString: @"<connection str>" notificationHubPath:@«<hub name>"]; [hub registerNativeWithDeviceToken:deviceToken];AndroidGoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); NotificationHub hub = new NotificationHub("<hub name>", "<connection str>", this); String regid = gcm.register(SENDER_ID);hub.register(regid);
@cloudbeatsch
var hub = NotificationHubClient.CreateClientFromConnectionString("<connection string>", “<hub name>");
hub.SendWindowsNativeNotificationAsync(@“<toast><visual>
<binding template="ToastText01"><text id="1">This is a very simple notification</text>
</binding></visual>
</toast>“);
hub.SendAppleNativeNotificationAsync(@“{ aps: {alert: "This is a very simple notification"
}}“);
hub.SendGcmNativeNotificationAsync(@“{"data" : { "msg" : "This is a very simple notification" }}");
@cloudbeatsch
templatesachieve platform independency
@cloudbeatsch
Android app
iOS app
{aps: {
alert: "$(msg)"}
}
notification hub
{ "data" : { "msg" : "$(msg)" }}
app back-end
hub.send(“{msg: “hello”}
”);
@cloudbeatsch
Android app
iOS app
{aps: {
alert: "hello"
}}
notification hub
{ "data" : { "msg" : “hello" }}
app back-end
hub.send(“{msg: “hello”}
”);
apns
gcm
@cloudbeatsch
templatespersonalize notifications
@cloudbeatsch
Android app
iOS app
{aps: {
alert: "$(msg_AF)"
}}
notification hub
{ "data" : { "msg" : "$(msg_EN)" }}
app back-end
hub.send(“{msg_EN: “good morning”}{msg_AF: “goeie môre”}
”);
@cloudbeatsch
Android app
iOS app
{aps: {
alert: "goeie môre"
}}
notification hub
{ "data" : { "msg" : “good morning" }}
app back-end
apns
gcm
hub.send(“{msg_EN: “good morning”}{msg_AF: “goeie môre”}
”);
good morning
goeiemôre
@cloudbeatsch
register templates:Bob: {“image”:“$(img_5_days_C_EN)”}Ben: {“image”:“$(img_3_days_F_EN)”}Peter: {“image”:“$(img_3_days_C_AF)”}
notification message:img_5_days_C_EN:”url1”, img_5_days_F_EN:”url2”,img_3_days_C_EN:”url3”, img_3_days_F_EN:”url4”,img_5_days_C_AF:”url5”, img_5_days_F_AF:”url6”,img_3_days_C_AF:”url7”, img_3_days_F_AF:”url8”,
@cloudbeatsch
tagsroute notifications based on topics
@cloudbeatsch
Android app
iOS app
register tags: Eastern_Cape
notification hub
register tags: Western_Cape
app back-end
tags: Western_Capemsg: “weather warning”msg: “weather warning”
weatherwarning
@cloudbeatsch
Android app
iOS app
register tags: Eastern_Cape
notification hub
register tags: Western_Cape
app back-end
tags: Western_Cape,Eastern_Capemsg: “weather warning”msg: “weather warning”
weatherwarning
weatherwarning
@cloudbeatsch
Android app
iOS app
register tags: Eastern_Cape,Western_Cape
notification hub
register tags: Western_Cape
app back-end
tags: Western_Capemsg: “weather warning”msg: “weather warning”
weatherwarning
weatherwarning
@cloudbeatsch
Android app
iOS app
register tags: Western_Cape,Eastern_Cape,Heavy_Rain
notification hub
register tags: Western_Cape,Gails,Big_Waves
app back-end
tags: (Western_Cape && Heavy_Rain)msg: “weather warning”msg: “weather warning”
weatherwarning
@cloudbeatsch
tags are just stringsuser:richardgroup:id && !user:richarddevice:sn0122299938user:richard && device:sn0122299938timezone:PST && follows:thaifoodversion:1.0 && platform:Android
@cloudbeatsch
demoweather warning app for south africa
@cloudbeatsch
under the hoodit’s the azure service bus
@cloudbeatsch
Gateway
Gateway
app back-end
pns
iOS app
Notification
Message Broker
GatewayStore
Registration Store
Messaging
Store
scale unit
@cloudbeatsch
in closing …
@cloudbeatsch
scaling push notificationsnotification hubs are your friends
@cloudbeatsch
interconnect things (aka IoT)service bus is a friend too
@cloudbeatsch
get startedwww.azure.com