SlideShare ist ein Scribd-Unternehmen logo
1 von 23
APIs, Stop Polling Let’s Go Streaming
Name
Phil Wilkins
OCI
August 2022
Speaker
PhilWilkins
Cloud Developer Evangelist
2 Copyright © 2022, Oracle and/or its affiliates
Philip.Wilkins@Oracle.com
https://bit.ly/devrel-slack-emea @Phil Wilkins
mp3monster.org / cloud-native.info / oracle-integration.cloud
linkedin.com/in/philwilkins
github.com/mp3monster
@mp3monster
©Disney (under Fair Use)
Downsides of API Polling
• Too frequent …
• Unnecessary server effort repeating the same queries
• Too much load and risk of service degradation
• Each API call carries an overhead of initiating the exchange
• Network bandwidth consumption transmitting duplicated data
• If content refresh frequency can impact user experience – try to do something
and the data has already changed
• Too infrequent …
• Data received too late to be actionable
• User experience – application content not refreshing quickly enough, and users
start to force app refreshes – typically more costly!
• Amount of data that may need to be cached is a function of the polling interval
3 Copyright © 2022, Oracle and/or its affiliates
STOP
POLLIN
G!
Before we go streaming, we need to consider …
• Security…
• Know who is getting what data
• Is data going to the requestor
• Satisfying consumer security needs
(assurance of legitimate origin when
pushing events)
• Is the Consumer consuming data…
• Recognizing consumer connection loss
• Consumer coping with data volume (back
pressure)
• Handling out of sequence or missing
events
• Only receiving data they’re allowed to get
(events & attributes)
• API documentation…
• Open API Specification – not geared to
Async / Streaming API specifications
• Consumer enablement e.g. tech availability
- libraries, SDKs, etc.
• Monetization of APIs…
• How might the charging model work if we’re
pushing events?
• Controlling data serving costs e.g. not
sending events that aren’t needed/wanted
• Ease of development & maintenance
• How well is the technology understood
• Is the solution maintainable?
4 Copyright © 2022, Oracle and/or its affiliates
The Make-Up of a Good API
5 Copyright © 2022, Oracle and/or its affiliates
Legalese
Authentication
&
Authorization
SDK
Test
Framework
Common ‘Streaming’ API options …
6 Copyright © 2022, Oracle and/or its affiliates
• Web Hooks (Inverted APIs)
• Web Sockets
• Server Sent Events
• GraphQL Subscriptions
• gRPC Streams
Trends on different Stream Techniques
7 Copyright © 2022, Oracle and/or its affiliates
Web
Socket
s
Web
Hooks
The
Others!
Web Sockets
• Web Sockets (WS) have been around 10-15 years
and formalized through IETF’s RFC6455
• There are a variety sub-protocols/specializations
• Some recognized by IANA2 e.g. STOMP & MQTT
• Custom sub-protocols – not recognized by IANA e.g.
something created yourself
• WS does have some challenges …
• It works at a lower level than REST (emphasis
on TCP rather than HTTP for traffic)
• Some organizations choose to prevent sockets
– the bidirectional nature means the risk of data
egress.
• Not same origin restrictions enforced like HTTP
• Resource hungry – the socket is not multiplexed
between requests but dedicated to 1 client
• Need to recognize when the client has failed to
close properly to release resources.
8 Copyright © 2022, Oracle and/or its affiliates
Client Serve
r
HTTP Handshake
Uses HTTP Upgrade
Header
Bidirectional messages
Full duplex
Channel Closed by 1 side
Connection is
persistent
1 https://caniuse.com/websockets
2 https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name
Load
Balancer??
Proxy?
Web Sockets
• More challenges …
• Some web proxies can’t differentiate between a
WS connection and a normal HTTP request in a
‘limbo’ state
• The conversation is stateful
• therefore, impact on managing load balancing etc.
• Depending on how data is exchanged over the socket –
may need to track conversation state
• The benefits …
• It is transient, so the client doesn’t have a
continuously open network port
• About 98% of browsers support WS today1
• Plenty of library implementations to ease the
workload
• Reduced overhead – 1 handshake until the
communication completes
9 Copyright © 2022, Oracle and/or its affiliates
Client Serve
r
HTTP Handshake
Uses HTTP Upgrade
Header
Bidirectional messages
Full duplex
Channel Closed by 1 side
Connection is
persistent
Serve
r
Serve
r
State
Cach
e
Server side
var WebSocket = require('ws');
var ws = new WebSocket('ws://localhost:8992/');
ws.on('open', function open() {
data = …
// something happens & prep data
ws.send(data);
});
ws.on('error', function(error) {console.log(error);});
ws.on('message', function(data, flags) {
console.log('Server said: ' + data);});
10 Copyright © 2022, Oracle and/or its affiliates
var WebSocketServer = require('ws').Server;
const wssPort = process.env.PORT || 8080;
const wss = new WebSocketServer({port: wssPort});
var clients = new Array;
function handleConnection(client, request) {
clients.push(client);
// add this client to the clients array
function endClient() {
var position = clients.indexOf(client);
clients.splice(position, 1);
console.log("connection closed"); }
function clientResponse(data) {
console.log(data); }
// set up client event listeners:
client.on('message', clientResponse);
client.on('close', endClient);
}
wss.on('connection', handleConnection);
Client side
• Example uses Node.js with Web Socket library
Load
Balancer
Proxy
Server Sent Events
• Developed around 2006 - EventSource API is
standardized as part of HTML5
• Supported by all major browsers
• Process follows
• Client supplies the server with the URL
• Server calls the URL provided and sends a
stream of events.
• Once the server decides it is finished it closes
the connection.
• Unlike Sockets – is only 1 direction and only closed
by the server.
• No elegant means to perform heartbeat or event
ack
• Does focus on HTTP level exchanges rather than
TCP – and gains the security restrictions
• More efficient than using long polling (call and wait
for an event)
11 Copyright © 2022, Oracle and/or its affiliates
Client Serve
r
HTTP Request
response
One way messages
Close channel
Serve
r
Serve
r
State
Cach
e
Web Hook
• Web Hooks (WH) is very half duplex (i.e. 1 end
communicating at a time)
• Client provides URI to be called on when something
happens – just like any other API call
• Some challenges …
• Client has a discoverable endpoint
• Security is better when information is pulled NOT
pushed
• If clients are transient, risk of someone else
getting the API call
• Expose endpoint for URL
• Some benefits …
• Simple to implement
• Security management approaches can help
protect clients e.g. client registers with a key to
be used when called
• Easier to load balance, exploit common OOTB
services such as an API Gateway for outbound
to track data (audit, attach security creds etc)
12 Copyright © 2022, Oracle and/or its affiliates
Client API Server
Register Endpoint
Client endpoint invoked
when needed
Serve
r
API Server
Deregister Endpoint
Registrations
Cache
Load
Balancer
Web Hook
• Improve security through API Gateway
• Audit outbound traffic
• Authenticate transmission request (egress
authorization)
• Attach client-provided credentials to outbound
traffic
• Out of the box features
13 Copyright © 2022, Oracle and/or its affiliates
Client API Server
Register Endpoint
Serve
r
API Server
Deregister Endpoint
Registrations
Cache
API Server
Client endpoint invoked
when needed
Load
Balancer
Proxy
GraphQL Subscriptions
• GraphQL Subscriptions (GQL Subs) defines how
subscriptions should functionally work – but not how
to implement
• Different implementations may use different
strategies, but WS is the most common
• Benefits of GQL Subs…
• Same benefits as a GQL request (tailored data
set, option for attribute level access controls, etc)
• Lower level mechanisms abstracted
• Challenges of GQL Subs …
• Lot of work on the server – ability to build cached
answers for all harder
• Need to consider potential variance or custom
sub-protocols imposing client constraints
14 Copyright © 2022, Oracle and/or its affiliates
Client Serve
r
Register subscription
(connection initialize)
Event(s) Pushed
Subscription Closed
by 1 side
Serve
r
Serve
r
State
Cach
e
HTTP Handshake
Connection ack
Other msgs e.g. event
acks
HTTP
Websocket
GraphQL – Basic Query
• Schemas with strong typing
• Schemas can define multiple entities
• Schemas support the idea of abstraction
through interfaces
• Different entities can be linked via common
attributes
15 Copyright © 2022, Oracle and/or its affiliates
Droid implements Character
{ id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
primaryFunction: String
}
interface Character
{ id: ID!
name: String!
friends: [Character]
appearsIn: [String]!
}
{
"data":
{
"droid":
{
"name": "C-3PO“
“primaryFunction”:
“Interpreter”
}
}
}
Query
{
droid(id: "2000")
{
name,
primaryFunction
}
}
type Query {droid(id: ID!): Droid }
type Mutation {deleteDroid(id: ID!)
type Mutation (addDroid(newDroid: Droid!} • Schemas can define different types of
operations
• Query  get
• Mutations  insert / update / delete
• Subscriptions  live query
• Operations can then be used
• Operations can define the attributes to
use/retrieve
Based on:https://github.com/graphql/swapi-graphql
GraphQL – Subscription
• Subscription much like a query
• Primary difference is we’re also stipulating
what we want as the query when data
changes.
Copyright © 2022, Oracle and/or its affiliates
Droid implements Character
{ id: ID!
name: String!
friends: [Character]
appearsIn: [Episode]!
primaryFunction: String
}
interface Character
{ id: ID!
name: String!
friends: [Character]
appearsIn: [String]!
}
type Query {droid(id: ID!): Droid }
type subscription (characterUpdate(id: ID!}
{onCharacterUpdated(id : ID)
{
id: ID!
name: String!
}
}
Based on:https://github.com/graphql/swapi-graphql
gRPC Streams
• HTTP/2 foundation escape constraints of HTTP
1.x
• Multiple streams per connection
• Enabled by different flow control
implementation
• Greater network level efficiencies
• Header compression & security
mechanisms
• Parallelism can be achieved
• Ability to have half or full duplex depending on
needs
• HTTP/2 does have challenges
• Does require infrastructure/software stack
to support HTTP/2
• Monitoring of HTTP/2 is harder to
implement
• Streams can’t be load balanced, so
17 Copyright © 2022, Oracle and/or its affiliates
Client Serve
r
Serve
r
Server
State
Cach
e
gRPC request
Server
pushed
uniary
stream
Event(s) Pushed
Summary record
Stream Closed
ack
gRPC request
Event(s) Pushed
Client
pushed
uniary
stream
Summary record
Stream Closed
ack
gRPC request
Event(s) Pushed
Stream Closed
Bidirectional
event
stream
ack
gRPC Expression
• The same considerations of normal data
structure definitions still apply – streaming or
otherwise
• The RPC definitions in Protobuf 2 & 3 define
whether the invocation will stream
• The stream initiation can include metadata
controlling the life of the stream (e.g. use of
setting a deadline to receive the data)
• API design needs to consider whether the
stream uses strategies like ping-pong to
manage the delivery of messages
Copyright © 2022, Oracle and/or its affiliates Based on:https://github.com/graphql/swapi-graphql
• The only difference between single calls and
streams is the keyword stream in the rpc
definition
• Position of stream in the rpc will dictate half or
full duplex
message Droid
{
Id id = 1;
string primaryFunction =2;
Character character = 3;
}
message Ids {
repeated uint32 id = 1;}
syntax = "proto3";
message Id {
uint32 id = 1;}
message Character {
Id id =1;
string name =2;
repeated string
appearsIn =3;
repeated Character
friends =4;
}
service GetService
{
rpc getDroidById (Id) returns (Droid) {}
rpc setCharacter (Character) {}
rpc getCharacters () returns (stream Character) {}
rpc shareCharacters (stream Character)
returns (stream Character) {}
}
Summary / Recommendations
19 Copyright © 2022, Oracle and/or its affiliates
Web Hooks Web Sockets Server Sent Events
(SSE)
GraphQL
Subscriptions
gRPC Streams
Pros • Technically simple &
proven
• Lowest common
denominator
• Each message can
be ack’d to server in
HTTP response
• Well supported
• Same connection for
bidirectional traffic
• Should consider SDK
to mask serialization
• Single direction calls
• More efficient than
webhooks for
multiple events
• All the power of
selective data
from GraphQL
• Often (not
always)
implemented
using
WebSockets
• Bi-directional
• Very efficient
• Easy to express
once you know
gRPC
• Exploits HTTP/2
performance
• Single or
bidirectional flow
Con
s
• Not very efficient
• Client exposed
endpoint for inbound
calls
• More work as having
to (de)serialize
payloads
• Lose some HTTP
level security
• Not so commonly
used
• Client exposed
endpoint for server to
call
• No means to ack
each message
• Potential for
differences in
implementation
– ideally provide
client with
additional info or
SDK
• Client needs to
have correct
code frame
• Needs HTTP/2
Also need to consider the
specifics of these API
Useful Background resources
Streaming API Application
• Why Oracle Hospitality adopted streaming
APIs - https://bit.ly/OHIPStreamingWhy
• How Oracle Hospitality decided on their
streaming technology -
https://bit.ly/OHIPStrategy
• JavaScript and Oracle Database subscribe to
data changes -
https://bit.ly/DBChangeSubscriptions
• Oracle Content Management uses GraphQL
https://bit.ly/GraphQLOCM
Technology Resources
• Web Socket Examples using Node.js
frameworks - https://tigoe.github.io/websocket-
examples/
• Documentation on different Streaming
mechanisms https://ably.com/
• Async API specification -
https://www.asyncapi.com/docs
20 Copyright © 2022, Oracle and/or its affiliates
OCI Architecture Center -- Free Content & More
URLS are https://oracle.com/goto/...
Reference
Architectures
GitHub - DevRel
/ref-archs
Playbooks
/playbooks /gh-devrel
/deployed
Built & Deployed Live Labs
/labs
Tutorials
/tutorial
Blogs
Developer Open Source
Learning Videos Apex PaaS Community
GitHub - Oracle
/gh-oracle
Cloud Customer
Connect
/connect
/open
/dev
/paas
/apex
/blog
/youtube
Oracle Community
/community
GitHub - Samples
/gh-samples
URLS are https://oracle.com/goto/...
Questions / Thank you
Copyright © 2022, Oracle and/or its affiliates
Phil Wilkins
Cloud Developer Evangelist
Philip.Wilkins@Oracle.com
bit.ly/devrel-slack-emea @Phil Wilkins
mp3monster.org / cloud-native.info / oracle-
integration.cloud
linkedin.com/in/philwilkins
github.com/mp3monster
@mp3monster
APIs, STOP Polling, lets go Streaming

Weitere ähnliche Inhalte

Ähnlich wie APIs, STOP Polling, lets go Streaming

Serverless patterns
Serverless patternsServerless patterns
Serverless patternsJesse Butler
 
How to Reduce Latency with Cloudflare Argo Smart Routing
How to Reduce Latency with Cloudflare Argo Smart RoutingHow to Reduce Latency with Cloudflare Argo Smart Routing
How to Reduce Latency with Cloudflare Argo Smart RoutingCloudflare
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Lohika_Odessa_TechTalks
 
Tech talk microservices debugging
Tech talk microservices debuggingTech talk microservices debugging
Tech talk microservices debuggingAndrey Kolodnitsky
 
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...jeckels
 
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...Amazon Web Services
 
The Current And Future State Of Service Mesh
The Current And Future State Of Service MeshThe Current And Future State Of Service Mesh
The Current And Future State Of Service MeshRam Vennam
 
Expect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesExpect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesBhakti Mehta
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...Josef Adersberger
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...QAware GmbH
 
Database failover from client perspective
Database failover from client perspectiveDatabase failover from client perspective
Database failover from client perspectivePriit Piipuu
 
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...Cloudera, Inc.
 
D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-SignalingOleg Levy
 
Achieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAAchieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAMarkus Michalewicz
 
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleJUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleC2B2 Consulting
 
Service Virtualization: What Testers Need to Know
Service Virtualization: What Testers Need to KnowService Virtualization: What Testers Need to Know
Service Virtualization: What Testers Need to KnowTechWell
 
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...Kai Wähner
 

Ähnlich wie APIs, STOP Polling, lets go Streaming (20)

Serverless patterns
Serverless patternsServerless patterns
Serverless patterns
 
Cloud APIs Overview Tucker
Cloud APIs Overview   TuckerCloud APIs Overview   Tucker
Cloud APIs Overview Tucker
 
How to Reduce Latency with Cloudflare Argo Smart Routing
How to Reduce Latency with Cloudflare Argo Smart RoutingHow to Reduce Latency with Cloudflare Argo Smart Routing
How to Reduce Latency with Cloudflare Argo Smart Routing
 
Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...Debugging Microservices - key challenges and techniques - Microservices Odesa...
Debugging Microservices - key challenges and techniques - Microservices Odesa...
 
Tech talk microservices debugging
Tech talk microservices debuggingTech talk microservices debugging
Tech talk microservices debugging
 
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
Oracle WebLogic Server 12c: Seamless Oracle Database Integration (with NEC, O...
 
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
Accelerating and Securing your Applications in AWS. In-depth look at Solving ...
 
The Current And Future State Of Service Mesh
The Current And Future State Of Service MeshThe Current And Future State Of Service Mesh
The Current And Future State Of Service Mesh
 
Expect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservicesExpect the unexpected: Prepare for failures in microservices
Expect the unexpected: Prepare for failures in microservices
 
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ... The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
 
JAVA
JAVAJAVA
JAVA
 
Database failover from client perspective
Database failover from client perspectiveDatabase failover from client perspective
Database failover from client perspective
 
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
Simplifying Hadoop with RecordService, A Secure and Unified Data Access Path ...
 
D1-3-Signaling
D1-3-SignalingD1-3-Signaling
D1-3-Signaling
 
Thick client application security assessment
Thick client  application security assessmentThick client  application security assessment
Thick client application security assessment
 
Achieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAAAchieving Continuous Availability for Your Applications with Oracle MAA
Achieving Continuous Availability for Your Applications with Oracle MAA
 
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleJUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
 
Service Virtualization: What Testers Need to Know
Service Virtualization: What Testers Need to KnowService Virtualization: What Testers Need to Know
Service Virtualization: What Testers Need to Know
 
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...
Confluent Platform 5.4 + Apache Kafka 2.4 Overview (RBAC, Tiered Storage, Mul...
 

Mehr von Phil Wilkins

API Design – More than just a Payload Definition
API Design – More than just a Payload DefinitionAPI Design – More than just a Payload Definition
API Design – More than just a Payload DefinitionPhil Wilkins
 
Is 12 Factor App Right About Logging
Is 12 Factor App Right About LoggingIs 12 Factor App Right About Logging
Is 12 Factor App Right About LoggingPhil Wilkins
 
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)Phil Wilkins
 
Oracle OCI APIs and SDK
Oracle OCI APIs and SDKOracle OCI APIs and SDK
Oracle OCI APIs and SDKPhil Wilkins
 
Api more than payload (2021 Update)
Api more than payload (2021 Update)Api more than payload (2021 Update)
Api more than payload (2021 Update)Phil Wilkins
 
API more than payload
API more than payloadAPI more than payload
API more than payloadPhil Wilkins
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapePhil Wilkins
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20Phil Wilkins
 
FluentD for end to end monitoring
FluentD for end to end monitoringFluentD for end to end monitoring
FluentD for end to end monitoringPhil Wilkins
 
Meetups - The Oracle Ace Way
Meetups - The Oracle Ace WayMeetups - The Oracle Ace Way
Meetups - The Oracle Ace WayPhil Wilkins
 
Apiary - A Developers Perspective
Apiary - A Developers PerspectiveApiary - A Developers Perspective
Apiary - A Developers PerspectivePhil Wilkins
 
Secrets of Custom API Policies on the Oracle API Platform
Secrets of Custom API Policies on the Oracle API PlatformSecrets of Custom API Policies on the Oracle API Platform
Secrets of Custom API Policies on the Oracle API PlatformPhil Wilkins
 
Oracle London Developer Meetup November 2018
Oracle London Developer Meetup November 2018Oracle London Developer Meetup November 2018
Oracle London Developer Meetup November 2018Phil Wilkins
 
London Oracle Developer Meetup - June 18 - Drones with APIs
London Oracle Developer Meetup - June 18 - Drones with APIsLondon Oracle Developer Meetup - June 18 - Drones with APIs
London Oracle Developer Meetup - June 18 - Drones with APIsPhil Wilkins
 
London Oracle Developer Meetup April 18
London Oracle Developer Meetup April 18London Oracle Developer Meetup April 18
London Oracle Developer Meetup April 18Phil Wilkins
 
Oracle Developer Meetup March 2018
Oracle Developer Meetup March 2018Oracle Developer Meetup March 2018
Oracle Developer Meetup March 2018Phil Wilkins
 
OracleDeveloperMeetup - London 19-12-17
OracleDeveloperMeetup - London 19-12-17OracleDeveloperMeetup - London 19-12-17
OracleDeveloperMeetup - London 19-12-17Phil Wilkins
 
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...Phil Wilkins
 
API Platform Cloud Service best practice - OOW17
API Platform Cloud Service best practice - OOW17API Platform Cloud Service best practice - OOW17
API Platform Cloud Service best practice - OOW17Phil Wilkins
 

Mehr von Phil Wilkins (20)

API Design – More than just a Payload Definition
API Design – More than just a Payload DefinitionAPI Design – More than just a Payload Definition
API Design – More than just a Payload Definition
 
Is 12 Factor App Right About Logging
Is 12 Factor App Right About LoggingIs 12 Factor App Right About Logging
Is 12 Factor App Right About Logging
 
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
GitHub Actions - using Free Oracle Cloud Infrastructure (OCI)
 
Oracle OCI APIs and SDK
Oracle OCI APIs and SDKOracle OCI APIs and SDK
Oracle OCI APIs and SDK
 
Api more than payload (2021 Update)
Api more than payload (2021 Update)Api more than payload (2021 Update)
Api more than payload (2021 Update)
 
API more than payload
API more than payloadAPI more than payload
API more than payload
 
How fluentd fits into the modern software landscape
How fluentd fits into the modern software landscapeHow fluentd fits into the modern software landscape
How fluentd fits into the modern software landscape
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
FluentD for end to end monitoring
FluentD for end to end monitoringFluentD for end to end monitoring
FluentD for end to end monitoring
 
Meetups - The Oracle Ace Way
Meetups - The Oracle Ace WayMeetups - The Oracle Ace Way
Meetups - The Oracle Ace Way
 
Apiary - A Developers Perspective
Apiary - A Developers PerspectiveApiary - A Developers Perspective
Apiary - A Developers Perspective
 
Secrets of Custom API Policies on the Oracle API Platform
Secrets of Custom API Policies on the Oracle API PlatformSecrets of Custom API Policies on the Oracle API Platform
Secrets of Custom API Policies on the Oracle API Platform
 
Terraform
TerraformTerraform
Terraform
 
Oracle London Developer Meetup November 2018
Oracle London Developer Meetup November 2018Oracle London Developer Meetup November 2018
Oracle London Developer Meetup November 2018
 
London Oracle Developer Meetup - June 18 - Drones with APIs
London Oracle Developer Meetup - June 18 - Drones with APIsLondon Oracle Developer Meetup - June 18 - Drones with APIs
London Oracle Developer Meetup - June 18 - Drones with APIs
 
London Oracle Developer Meetup April 18
London Oracle Developer Meetup April 18London Oracle Developer Meetup April 18
London Oracle Developer Meetup April 18
 
Oracle Developer Meetup March 2018
Oracle Developer Meetup March 2018Oracle Developer Meetup March 2018
Oracle Developer Meetup March 2018
 
OracleDeveloperMeetup - London 19-12-17
OracleDeveloperMeetup - London 19-12-17OracleDeveloperMeetup - London 19-12-17
OracleDeveloperMeetup - London 19-12-17
 
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...
Look at Oracle Integration Cloud – its relationship to ICS. Customer use Case...
 
API Platform Cloud Service best practice - OOW17
API Platform Cloud Service best practice - OOW17API Platform Cloud Service best practice - OOW17
API Platform Cloud Service best practice - OOW17
 

Kürzlich hochgeladen

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 

Kürzlich hochgeladen (20)

DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

APIs, STOP Polling, lets go Streaming

  • 1. APIs, Stop Polling Let’s Go Streaming Name Phil Wilkins OCI August 2022
  • 2. Speaker PhilWilkins Cloud Developer Evangelist 2 Copyright © 2022, Oracle and/or its affiliates Philip.Wilkins@Oracle.com https://bit.ly/devrel-slack-emea @Phil Wilkins mp3monster.org / cloud-native.info / oracle-integration.cloud linkedin.com/in/philwilkins github.com/mp3monster @mp3monster
  • 3. ©Disney (under Fair Use) Downsides of API Polling • Too frequent … • Unnecessary server effort repeating the same queries • Too much load and risk of service degradation • Each API call carries an overhead of initiating the exchange • Network bandwidth consumption transmitting duplicated data • If content refresh frequency can impact user experience – try to do something and the data has already changed • Too infrequent … • Data received too late to be actionable • User experience – application content not refreshing quickly enough, and users start to force app refreshes – typically more costly! • Amount of data that may need to be cached is a function of the polling interval 3 Copyright © 2022, Oracle and/or its affiliates STOP POLLIN G!
  • 4. Before we go streaming, we need to consider … • Security… • Know who is getting what data • Is data going to the requestor • Satisfying consumer security needs (assurance of legitimate origin when pushing events) • Is the Consumer consuming data… • Recognizing consumer connection loss • Consumer coping with data volume (back pressure) • Handling out of sequence or missing events • Only receiving data they’re allowed to get (events & attributes) • API documentation… • Open API Specification – not geared to Async / Streaming API specifications • Consumer enablement e.g. tech availability - libraries, SDKs, etc. • Monetization of APIs… • How might the charging model work if we’re pushing events? • Controlling data serving costs e.g. not sending events that aren’t needed/wanted • Ease of development & maintenance • How well is the technology understood • Is the solution maintainable? 4 Copyright © 2022, Oracle and/or its affiliates
  • 5. The Make-Up of a Good API 5 Copyright © 2022, Oracle and/or its affiliates Legalese Authentication & Authorization SDK Test Framework
  • 6. Common ‘Streaming’ API options … 6 Copyright © 2022, Oracle and/or its affiliates • Web Hooks (Inverted APIs) • Web Sockets • Server Sent Events • GraphQL Subscriptions • gRPC Streams
  • 7. Trends on different Stream Techniques 7 Copyright © 2022, Oracle and/or its affiliates Web Socket s Web Hooks The Others!
  • 8. Web Sockets • Web Sockets (WS) have been around 10-15 years and formalized through IETF’s RFC6455 • There are a variety sub-protocols/specializations • Some recognized by IANA2 e.g. STOMP & MQTT • Custom sub-protocols – not recognized by IANA e.g. something created yourself • WS does have some challenges … • It works at a lower level than REST (emphasis on TCP rather than HTTP for traffic) • Some organizations choose to prevent sockets – the bidirectional nature means the risk of data egress. • Not same origin restrictions enforced like HTTP • Resource hungry – the socket is not multiplexed between requests but dedicated to 1 client • Need to recognize when the client has failed to close properly to release resources. 8 Copyright © 2022, Oracle and/or its affiliates Client Serve r HTTP Handshake Uses HTTP Upgrade Header Bidirectional messages Full duplex Channel Closed by 1 side Connection is persistent 1 https://caniuse.com/websockets 2 https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name
  • 9. Load Balancer?? Proxy? Web Sockets • More challenges … • Some web proxies can’t differentiate between a WS connection and a normal HTTP request in a ‘limbo’ state • The conversation is stateful • therefore, impact on managing load balancing etc. • Depending on how data is exchanged over the socket – may need to track conversation state • The benefits … • It is transient, so the client doesn’t have a continuously open network port • About 98% of browsers support WS today1 • Plenty of library implementations to ease the workload • Reduced overhead – 1 handshake until the communication completes 9 Copyright © 2022, Oracle and/or its affiliates Client Serve r HTTP Handshake Uses HTTP Upgrade Header Bidirectional messages Full duplex Channel Closed by 1 side Connection is persistent Serve r Serve r State Cach e
  • 10. Server side var WebSocket = require('ws'); var ws = new WebSocket('ws://localhost:8992/'); ws.on('open', function open() { data = … // something happens & prep data ws.send(data); }); ws.on('error', function(error) {console.log(error);}); ws.on('message', function(data, flags) { console.log('Server said: ' + data);}); 10 Copyright © 2022, Oracle and/or its affiliates var WebSocketServer = require('ws').Server; const wssPort = process.env.PORT || 8080; const wss = new WebSocketServer({port: wssPort}); var clients = new Array; function handleConnection(client, request) { clients.push(client); // add this client to the clients array function endClient() { var position = clients.indexOf(client); clients.splice(position, 1); console.log("connection closed"); } function clientResponse(data) { console.log(data); } // set up client event listeners: client.on('message', clientResponse); client.on('close', endClient); } wss.on('connection', handleConnection); Client side • Example uses Node.js with Web Socket library
  • 11. Load Balancer Proxy Server Sent Events • Developed around 2006 - EventSource API is standardized as part of HTML5 • Supported by all major browsers • Process follows • Client supplies the server with the URL • Server calls the URL provided and sends a stream of events. • Once the server decides it is finished it closes the connection. • Unlike Sockets – is only 1 direction and only closed by the server. • No elegant means to perform heartbeat or event ack • Does focus on HTTP level exchanges rather than TCP – and gains the security restrictions • More efficient than using long polling (call and wait for an event) 11 Copyright © 2022, Oracle and/or its affiliates Client Serve r HTTP Request response One way messages Close channel Serve r Serve r State Cach e
  • 12. Web Hook • Web Hooks (WH) is very half duplex (i.e. 1 end communicating at a time) • Client provides URI to be called on when something happens – just like any other API call • Some challenges … • Client has a discoverable endpoint • Security is better when information is pulled NOT pushed • If clients are transient, risk of someone else getting the API call • Expose endpoint for URL • Some benefits … • Simple to implement • Security management approaches can help protect clients e.g. client registers with a key to be used when called • Easier to load balance, exploit common OOTB services such as an API Gateway for outbound to track data (audit, attach security creds etc) 12 Copyright © 2022, Oracle and/or its affiliates Client API Server Register Endpoint Client endpoint invoked when needed Serve r API Server Deregister Endpoint Registrations Cache
  • 13. Load Balancer Web Hook • Improve security through API Gateway • Audit outbound traffic • Authenticate transmission request (egress authorization) • Attach client-provided credentials to outbound traffic • Out of the box features 13 Copyright © 2022, Oracle and/or its affiliates Client API Server Register Endpoint Serve r API Server Deregister Endpoint Registrations Cache API Server Client endpoint invoked when needed
  • 14. Load Balancer Proxy GraphQL Subscriptions • GraphQL Subscriptions (GQL Subs) defines how subscriptions should functionally work – but not how to implement • Different implementations may use different strategies, but WS is the most common • Benefits of GQL Subs… • Same benefits as a GQL request (tailored data set, option for attribute level access controls, etc) • Lower level mechanisms abstracted • Challenges of GQL Subs … • Lot of work on the server – ability to build cached answers for all harder • Need to consider potential variance or custom sub-protocols imposing client constraints 14 Copyright © 2022, Oracle and/or its affiliates Client Serve r Register subscription (connection initialize) Event(s) Pushed Subscription Closed by 1 side Serve r Serve r State Cach e HTTP Handshake Connection ack Other msgs e.g. event acks HTTP Websocket
  • 15. GraphQL – Basic Query • Schemas with strong typing • Schemas can define multiple entities • Schemas support the idea of abstraction through interfaces • Different entities can be linked via common attributes 15 Copyright © 2022, Oracle and/or its affiliates Droid implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! primaryFunction: String } interface Character { id: ID! name: String! friends: [Character] appearsIn: [String]! } { "data": { "droid": { "name": "C-3PO“ “primaryFunction”: “Interpreter” } } } Query { droid(id: "2000") { name, primaryFunction } } type Query {droid(id: ID!): Droid } type Mutation {deleteDroid(id: ID!) type Mutation (addDroid(newDroid: Droid!} • Schemas can define different types of operations • Query  get • Mutations  insert / update / delete • Subscriptions  live query • Operations can then be used • Operations can define the attributes to use/retrieve Based on:https://github.com/graphql/swapi-graphql
  • 16. GraphQL – Subscription • Subscription much like a query • Primary difference is we’re also stipulating what we want as the query when data changes. Copyright © 2022, Oracle and/or its affiliates Droid implements Character { id: ID! name: String! friends: [Character] appearsIn: [Episode]! primaryFunction: String } interface Character { id: ID! name: String! friends: [Character] appearsIn: [String]! } type Query {droid(id: ID!): Droid } type subscription (characterUpdate(id: ID!} {onCharacterUpdated(id : ID) { id: ID! name: String! } } Based on:https://github.com/graphql/swapi-graphql
  • 17. gRPC Streams • HTTP/2 foundation escape constraints of HTTP 1.x • Multiple streams per connection • Enabled by different flow control implementation • Greater network level efficiencies • Header compression & security mechanisms • Parallelism can be achieved • Ability to have half or full duplex depending on needs • HTTP/2 does have challenges • Does require infrastructure/software stack to support HTTP/2 • Monitoring of HTTP/2 is harder to implement • Streams can’t be load balanced, so 17 Copyright © 2022, Oracle and/or its affiliates Client Serve r Serve r Server State Cach e gRPC request Server pushed uniary stream Event(s) Pushed Summary record Stream Closed ack gRPC request Event(s) Pushed Client pushed uniary stream Summary record Stream Closed ack gRPC request Event(s) Pushed Stream Closed Bidirectional event stream ack
  • 18. gRPC Expression • The same considerations of normal data structure definitions still apply – streaming or otherwise • The RPC definitions in Protobuf 2 & 3 define whether the invocation will stream • The stream initiation can include metadata controlling the life of the stream (e.g. use of setting a deadline to receive the data) • API design needs to consider whether the stream uses strategies like ping-pong to manage the delivery of messages Copyright © 2022, Oracle and/or its affiliates Based on:https://github.com/graphql/swapi-graphql • The only difference between single calls and streams is the keyword stream in the rpc definition • Position of stream in the rpc will dictate half or full duplex message Droid { Id id = 1; string primaryFunction =2; Character character = 3; } message Ids { repeated uint32 id = 1;} syntax = "proto3"; message Id { uint32 id = 1;} message Character { Id id =1; string name =2; repeated string appearsIn =3; repeated Character friends =4; } service GetService { rpc getDroidById (Id) returns (Droid) {} rpc setCharacter (Character) {} rpc getCharacters () returns (stream Character) {} rpc shareCharacters (stream Character) returns (stream Character) {} }
  • 19. Summary / Recommendations 19 Copyright © 2022, Oracle and/or its affiliates Web Hooks Web Sockets Server Sent Events (SSE) GraphQL Subscriptions gRPC Streams Pros • Technically simple & proven • Lowest common denominator • Each message can be ack’d to server in HTTP response • Well supported • Same connection for bidirectional traffic • Should consider SDK to mask serialization • Single direction calls • More efficient than webhooks for multiple events • All the power of selective data from GraphQL • Often (not always) implemented using WebSockets • Bi-directional • Very efficient • Easy to express once you know gRPC • Exploits HTTP/2 performance • Single or bidirectional flow Con s • Not very efficient • Client exposed endpoint for inbound calls • More work as having to (de)serialize payloads • Lose some HTTP level security • Not so commonly used • Client exposed endpoint for server to call • No means to ack each message • Potential for differences in implementation – ideally provide client with additional info or SDK • Client needs to have correct code frame • Needs HTTP/2 Also need to consider the specifics of these API
  • 20. Useful Background resources Streaming API Application • Why Oracle Hospitality adopted streaming APIs - https://bit.ly/OHIPStreamingWhy • How Oracle Hospitality decided on their streaming technology - https://bit.ly/OHIPStrategy • JavaScript and Oracle Database subscribe to data changes - https://bit.ly/DBChangeSubscriptions • Oracle Content Management uses GraphQL https://bit.ly/GraphQLOCM Technology Resources • Web Socket Examples using Node.js frameworks - https://tigoe.github.io/websocket- examples/ • Documentation on different Streaming mechanisms https://ably.com/ • Async API specification - https://www.asyncapi.com/docs 20 Copyright © 2022, Oracle and/or its affiliates
  • 21. OCI Architecture Center -- Free Content & More URLS are https://oracle.com/goto/... Reference Architectures GitHub - DevRel /ref-archs Playbooks /playbooks /gh-devrel /deployed Built & Deployed Live Labs /labs Tutorials /tutorial Blogs Developer Open Source Learning Videos Apex PaaS Community GitHub - Oracle /gh-oracle Cloud Customer Connect /connect /open /dev /paas /apex /blog /youtube Oracle Community /community GitHub - Samples /gh-samples URLS are https://oracle.com/goto/...
  • 22. Questions / Thank you Copyright © 2022, Oracle and/or its affiliates Phil Wilkins Cloud Developer Evangelist Philip.Wilkins@Oracle.com bit.ly/devrel-slack-emea @Phil Wilkins mp3monster.org / cloud-native.info / oracle- integration.cloud linkedin.com/in/philwilkins github.com/mp3monster @mp3monster

Hinweis der Redaktion

  1. Webhook icon - https://icon-icons.com/icon/webhook/138018
  2. https://betterprogramming.pub/understand-graphql-subscriptions-in-java-with-a-tic-tac-toe-game-832ba2729e6d