Monday, 2 May 2016

AWS SNS

Overview
  • Global message delivery service

Use cases
  • S3 bucket notifications (e.g. do something on object PUT)
  • Mobile push notifications (e.g. breaking news, marketing, alerts)
  • SMS messaging
  • In front of SQS if there is another listener (e.g. logging)
  • "Bus" architectures: SNS + n * SQS
    • N pub to M sub
    • 1 pub to N sub (fan-out)
    • N pub to 1 sub
  • VoIP push notifications (iOS)
    • incoming call wake up the application

Model
  • Publisher
  • Topic 
    • may represent area of interest (e.g. critical notifications)
    • may represent individuals and subscribers with their devices
    • may map to campaign
    • max 256 characters (alphanumeric, "_", "-")
  • Subscriber (endpoints)
  • SMS
  • Publish
  • sms

Message
  • Max payload = 256KB
    • possibly related to SQS max payload
  • MessageId
  • TopicArn
  • Unsubscribe Link
  • Subject (optional)
  • Signature (Signature Type)

Message Attributes
  • Structured metadata items, e.g.
    • timestamps
    • geospatial data
    • signatures
    • identifiers
  • Sent along message body
    • Subscriber can use them to determine if he should process the rest
      • Can be filtered out even earlier - see Subscription Filter policy
    • Similar to headers in HTTP
  • For SQS endpoint
    • Up to 10 name-value-type triplets
    • Type: String, Binary, Number
  • For Mobile Push endpoint
    • Platform specific metadata

Subscription Attributes
  • RawMessageDelivery - message received exactly as published
    • by default JSON encoding
    • Supported by: HTTP(S) and SQS
  • Subscription Filter policy
    • Use message attributes to filter out unwanted messages

Topic policy
  • Resource-based permissions
  • Publishers
    • Owner, Other AWS Accounts, Anonymous
  • Subscribers
    • Owner, Other AWS Accounts, Anonymous
      • Conditions: delivery protocol, endpoint regex, SourceOwner (CloudTrail)
  • Similiar to SQS resource policy
  • Use case
    • Grant "AWS S3 Service" permissions to insert notifications about Bucket Events

HTTP Delivery Policy
  • Maximum receive rate
    • number of messages sent per second
    • messages awaiting delivery are held for max 60 minutes and then dropped
    • smooths out bursts
  • Level
    • Topic
    • Subscription (overrides topic unless topic prohibits override explicitely)
  • Retry
    • Condition
      • HTTP 500-599 OR < 200 OR > 599
      • Timeout (15 seconds)
      • Connection error
    • Phases (allow to shape retry behavior)
      • Immediate retry phase (no delay phase)
        • immediately after failed attempt
        • parameter: retries with no delay
      • Pre-Backoff Phase 
        • before backoff function is applied
        • parameter: minimum delay retries, minimum delay (time between attempts)
      • Backoff phase
        • control delay between retries
        • parameter: minimum delay, maximum delay,
        • parameter: retry backoff function (calculate time delay)
          • linear, arithmetic, geometric, exponential
      • Post-backoff phase
        • When backoff function reaches the maximum delay 
        • parameter: maximum delay


References
  • https://developers.google.com/cloud-messaging/concept-options#lifetime

No comments:

Post a Comment