Presentation of an article published at the 11th workshop on Linked Data on the Web (LDOW2018), co-located with the Web Conference 2018.
Article: https://hal.archives-ouvertes.fr/hal-01722792
We hypothesize that harnessing the Semantic Web standards to enable automatic combination of Linked Data and non-RDF Web APIs data could trigger novel cross-fertilization scenarios.
To achieve this goal, we define the SPARQL Micro-Service architecture. A SPARQL micro-service is a lightweight, task-specific SPARQL endpoint that provides access to a small, resource-centric, virtual graph, while dynamically assigning dereferenceable URIs to Web API resources that do not have URIs beforehand. The graph is delineated by the Web API service being wrapped, the arguments passed to this service, and the restricted types of RDF triples that this SPARQL micro-service is designed to spawn. In this context, we argue that full SPARQL expressiveness can be supported efficiently without jeopardizing servers availability. Eventually, we believe that an ecosystem of SPARQL micro-services could emerge from independent service providers, enabling Linked Data-based applications to glean pieces of data from a wealth of distributed, scalable and reliable services. We describe an experimentation where we dynamically augment biodiversity-related Linked Data with data from Flickr, MusicBrainz and the Macauley scientific media library.
20240509 QFM015 Engineering Leadership Reading List April 2024.pdf
SPARQL Micro-Services: Lightweight Integration of Web APIs and Linked Data
1. 1Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
F. Michel, C. Faron-Zucker, F. Gandon
Université Côte d’Azur, CNRS, Inria, I3S, France
SPARQL Micro-Services:
Lightweight Integration of Web APIs and Linked Data
11th International Workshop on Linked Data on the Web (LDOW)
April 23rd 2018, Lyon, France
2. 2Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Monolithic vs. Micro-services Architectures
User Interface
Business Layer
Data Layer
Monolithic Architecture Micro-services Architecture
User Interface
3. 3Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Micro-services Architecture(s)
a.k.a. fined-grained SOA, serverless architecture
Principle: decompose the app into multiple services
• Fine-grained: focused on a simple, unique function (minimal)
• Lightweight
• Loosely coupled (complete)
• Independently deployable
• Standard APIs, common ways of identifying resources (composable)
User Interface
Benefits
• Modularity: applications easier to test and deploy (continuous deployment)
• Elasticity: scale one micro-service up or down independently of other services (e.g. app containers)
• Language/technology freedom (polyglot application)
4. 4Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Can we leverage µ-service principles to design LD-based applications?
LD Application
URI
lookup
Link
traversalTriple
store
Query
expansion
SOLID
data
store
Authentication
5. 5Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Bridging Web APIs and Linked Data
LD-based application Several common issues to tackle:
• “REST-like” is not RESTful:
• standard formats (e.g. JSON, XML) but
proprietary vocabularies
• documented in web pages but not
machine-processable
• no hyperlinks
• Internal resource identifiers
• What appropriate interface:
LD document, REST (TPF, LDP), SPARQL?
6. 6Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
The SPARQL Micro-services Architecture
http://getPhotosByTag.example.org/sparql?tags=bridge
https://api.flickr.com/services/rest?
method=flickr.photos.search&format=json&api_key=…&
tags=bridge
Sµ
ArgW
SW
ArgW
Sµ translates Sw‘s response into an RDF graph
and evaluates the SPARQL query against this graph.
Lightweight method to query a Web API with SPARQL, and
assign dereferenceable URIs to Web API resources
7. 7Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
A SPARQL micro-service is a configurable SPARQL endpoint
whose arguments delineate the virtual graph that is being queried.
8. 8Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Fine-grained (one API, one service at a time)
Lightweight
Loosely-coupled (complete s/w unit)
Independently deployable (e.g. Docker)
Standard API and resource naming
Comply with standards
SPARQL query language and protocol
No extension needed
Pay-as-you-go
Develop µ-services along with new arising needs
Simplicity
Configuration-based provisioning
Hide Web API technicalities
Alignment with common/domain vocabularies
SPARQL Micro-services Characteristics
Sµ
ArgW
http://getPhotosByTag.example.org/sparql?tags=bridge
9. 9Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Alternative options to pass µ-service arguments
SELECT ?img WHERE {
SERVICE <http://hostname/flickr/getPhotosByGroupByTag>
{ ?photo foaf:depiction ?img.
<http://hostname/flickr/getPhotosByGroupByTag>
a api:Service; api:execution [
api:param [ api:name "group_id"; api:value "806927@N20" ];
api:param [ api:name "tags"; api:value ?tag ].
].
}}
SELECT ?img WHERE {
SERVICE <http://hostname/flickr/getPhotosByGroupByTag>
{ ?photo foaf:depiction ?img;
api:group_id "806927@N20";
api:tags "bridge".
}}
SELECT ?img WHERE {
SERVICE <http://hostname/flickr/getPhotosByGroupByTag>
{ ?photo foaf:depiction ?img.
BIND("806927@N20" AS ?group_id)
BIND("bridge" AS ?tags)
}}
Arguments made explicit can be reused in the graph pattern.
Create new terms for each µ-service.
Terms possibly technical for which we do not want to define
ontological terms.
Subject of these triples?
Little new terms, possibly coming from existing ontologies
Uniform manner to pass arguments.
Additional triples with somewhat artificial semantics:
configure the service (how) but do not describe the
searched resources (what).
No new terms needed.
Simple and easy-to-read.
Predefined variables with somewhat artificial semantics:
configure the service (how) but do not describe the
searched resources (what).
10. 10Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Prototype implementation for JSON-based Web APIs
SPARQL Client Service Logics Web API
JSON-LD
Profile
SPARQL
INSERT
HTTP
query
JSON
response
Triple
store
SPARQL Micro-Service
(1)
(4)
(2)
(3)
SPARQL query processing
https://github.com/frmichel/sparql-micro-service
https://hub.docker.com/u/frmichel
11. 11Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Prototype implementation for JSON-based Web APIs
Service Logics Web API
JSON-LD
Profile
SPARQL
CONSTRUCT
HTTP
query
JSON
response
Triple
store
SPARQL Micro-Service
LD Client Web Server
URI dereferencing
(1)
(6)
(3)
(4)
(2)
(5)
The URI is rewritten into an invocation of the appropriate
SPARQL micro-service that returns the result of a CONSTRUCT query.
The result is transparently proxied back to the client.
http://example.org/photo/472495
12. 12Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Evaluation: 2% to 4% overhead compared to direct Web API query
Biodiversity related use-case to retrieve:
photos from Flickr,
audio recordings from the Macauley Library,
music tunes from MusicBrainz
Query execution time (in seconds) for individual SPARQL micro-services.
The last column is the overhead imposed by the SPARQL micro-service compared to a direct Web API query.
13. 13Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Impact of the SPARQL engine evaluation strategy
Independence of graph patterns:
Virtuoso OS follow the worst evaluation strategy
(https://github.com/openlink/virtuoso-opensource/issues/724).
Parallelism:
Virtuoso OS and Corese-KGRAM do not evaluate SERVICE clauses in parallel although they are
independent.
15. 15Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
Richer, self-describing interface
Self-describing metadata
• Expected parameters, types of triples generated
• Paging mechanism
Follow the idea of Triple Pattern Fragments
• Self-describing, uniform interface: triple + metadata + hypermedia controls
• Allow navigate from one fragment (or page) to another
Is SPARQL the right type of interface?
• Embed metadata within SPARQL results (SELECT, ASK query forms)?
• Restrict SPARQL Query to CONSTRUCT and DESCRIBE query forms?
• Define a Graph Pattern Fragment interface?
16. 16Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
General perspectives
Push forward the reflection about micro-services vs. LD-based apps
• other types of data sources
• other types of services
Most Web APIs provide R/W access
SPARQL Update micro-service to achieve R/W Web of Data?
17. 17Franck MICHEL - Université Côte d’Azur, CNRS, Inria, I3S, France
https://github.com/frmichel/sparql-micro-service
https://hub.docker.com/u/frmichel
Citation:
Michel F., Faron-Zucker C. & Gandon F (2018). SPARQL Micro-Services:
Lightweight Integration of Web APIs and Linked Data. In Proceedings of
the Linked Data on the Web Workshop (LDOW2018). Lyon, France.