Scaling push notifications to millions of devices using notification hubs

35
@cloudbeatsch Beat Schwegler Microsoft Corporation Twitter: @cloudbeatsch Blog: http://cloudbeatsch.com scaling push notifications to millions of devices using notification hubs

description

 

Transcript of Scaling push notifications to millions of devices using notification hubs

Page 1: 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

Page 2: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

push notificationsintegral part of modern applications

Page 3: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

different platforms : gcm - apns - mpnssimilar concepts and architecture

Page 4: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

platformnotification

service

app back-end

app

1

2

3

4retrieve handlestore handle

send notification

Page 5: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

platformnotification

service

app back-end

1

2

3

4

Client Notification

Service

App

retrieve handlestore handlesend notification

Page 6: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

unique token per device and apppersist, refresh and retrieve millions of tokens

challenge - registration management

Page 7: Scaling push notifications to millions of devices using notification hubs

@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

Page 8: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

personalized per user and/or devicelanguage, message format, visualsmetrics (currency, temperature, length …)

challenge - message personalization

Page 9: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

users/apps subscribe to topics only interested in rugby and tennis newsand only when written by Rob, Ben or Paul

challenge - message routing

Page 10: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

notification hubshighly scalable pub/sub based service

Page 11: Scaling push notifications to millions of devices using notification hubs

@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+

Page 12: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

platformnotification

service

app back-end

app

1

2

4

5

retrieve handlestore handlesend notification

notification hub

3

Page 13: Scaling push notifications to millions of devices using notification hubs

@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

Page 14: Scaling push notifications to millions of devices using notification hubs

@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);

Page 15: Scaling push notifications to millions of devices using notification hubs

@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" }}");

Page 16: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

templatesachieve platform independency

Page 17: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

Android app

iOS app

{aps: {

alert: "$(msg)"}

}

notification hub

{ "data" : { "msg" : "$(msg)" }}

app back-end

hub.send(“{msg: “hello”}

”);

Page 18: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

Android app

iOS app

{aps: {

alert: "hello"

}}

notification hub

{ "data" : { "msg" : “hello" }}

app back-end

hub.send(“{msg: “hello”}

”);

apns

gcm

Page 19: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

templatespersonalize notifications

Page 20: Scaling push notifications to millions of devices using notification hubs

@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”}

”);

Page 21: Scaling push notifications to millions of devices using notification hubs

@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

Page 22: Scaling push notifications to millions of devices using notification hubs

@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”,

Page 23: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

tagsroute notifications based on topics

Page 24: Scaling push notifications to millions of devices using notification hubs

@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

Page 25: Scaling push notifications to millions of devices using notification hubs

@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

Page 26: Scaling push notifications to millions of devices using notification hubs

@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

Page 27: Scaling push notifications to millions of devices using notification hubs

@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

Page 28: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

tags are just stringsuser:richardgroup:id && !user:richarddevice:sn0122299938user:richard && device:sn0122299938timezone:PST && follows:thaifoodversion:1.0 && platform:Android

Page 29: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

demoweather warning app for south africa

Page 30: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

under the hoodit’s the azure service bus

Page 31: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

Gateway

Gateway

app back-end

pns

iOS app

Notification

Message Broker

GatewayStore

Registration Store

Messaging

Store

scale unit

Page 32: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

in closing …

Page 33: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

scaling push notificationsnotification hubs are your friends

Page 34: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

interconnect things (aka IoT)service bus is a friend too

Page 35: Scaling push notifications to millions of devices using notification hubs

@cloudbeatsch

get startedwww.azure.com