SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
© 2019 GraphAware Ltd. All rights reserved.
Fix your microservice architecture
Using graph analysis
Nicolas Mervaillie - Principal Consultant @ GraphAware
graphaware.com
@graph_aware, @nmervaillie
#neo4j and #jQAssistant
© 2019 GraphAware Ltd. All rights reserved.
@nmervaillie
https://www.linkedin.com/in/nicolas-mervaillie-a2b9876/
© 2019 GraphAware Ltd. All rights reserved.
Microservices…. theory vs reality
Photo by Alphacolor on Unsplash Photo by Rick Mason on Unsplash
© 2019 GraphAware Ltd. All rights reserved.
Not everyone is etfli or
Photo by Tommy Lisbin on Unsplash
© 2019 GraphAware Ltd. All rights reserved.
Code is a Graph!
• Detect anti-patterns
• Impact analysis
• Better data governance
• Improve communication between teams
© 2019 GraphAware Ltd. All rights reserved.
Let’s try on an example application
https://github.com/sqshq/PiggyMetrics
./jqassistant.sh scan -f PiggyMetrics/account-service/target/account-service.jar, 
PiggyMetrics/auth-service/target/auth-service.jar,
PiggyMetrics/notification-service/target/notification-service.jar,
PiggyMetrics/statistics-service/target/statistics-service.jar,
PiggyMetrics/config/target/config.jar
© 2019 GraphAware Ltd. All rights reserved.
@RestController
@RequestMapping("/users")
public class UserController {
@Autowired
private UserService userService;
@RequestMapping(value = "/current", method = RequestMethod.GET)
public Principal getUser(Principal principal) {
return principal;
}
@PreAuthorize("#oauth2.hasScope('server')")
@RequestMapping(method = RequestMethod.POST)
public void createUser(@Valid @RequestBody User user) {
userService.create(user);
}
}
How does this translate into a graph ?
© 2019 GraphAware Ltd. All rights reserved.
© 2019 GraphAware Ltd. All rights reserved.
We can define higher level concepts
• APIs
• Software architecture
• Engineering practices
• …
OK, but what about my loosely coupled microservices?
Photo by ⻉贝莉⼉儿 NG on Unsplash
© 2019 GraphAware Ltd. All rights reserved.
REST Endpoints
MATCH (cls:Class)-[:DECLARES]->(endpoint)-[:ANNOTATED_BY]->(ann:Annotation)-[:OF_TYPE]->(:Type{name:"RequestMapping"})
WHERE cls.fqn starts with 'com.'
OPTIONAL MATCH (ann)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value)
OPTIONAL MATCH (ann)-[:HAS]->(:Value{name:"method"})-[:CONTAINS]->()-[:IS]->(httpMethod:Field)
SET endpoint:Endpoint
SET endpoint.method = split(httpMethod.signature, " ")[1]
SET endpoint.url = url.value
RETURN cls.fqn, endpoint.url, endpoint.method
@RequestMapping
Annotation
HTTP

url/method
© 2019 GraphAware Ltd. All rights reserved.
Feign (HTTP) clients
MATCH (client:Interface)-[:DECLARES]->(m:Method)
WHERE client.fqn STARTS WITH "com."
AND (client)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(:Type{fqn:"org.springframework.cloud.openfeign.FeignClient"})
MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value)
MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:HAS]->(:Value{name:"method"})-[:CONTAINS]->()-[:IS]-
>(httpMethod:Field)
SET m:FeignClient
SET m.url = apoc.text.regreplace(url.value, '{.*}', '{}')
SET m.httpMethod = split(httpMethod.signature, ' ')[1]
return m.name, m.httpMethod, m.url
© 2019 GraphAware Ltd. All rights reserved.
To materialize HTTP calls in the graph
MATCH (client:FeignClient), (endpoint:Endpoint)
WHERE client.url=endpoint.fullUrl and client.httpMethod=endpoint.method
MERGE (client)-[:INVOKES_REMOTE]->(endpoint)
RETURN client, endpoint
© 2019 GraphAware Ltd. All rights reserved.
MATCH (callerService:Artifact)-[:CONTAINS]-(callerClass:Type)-[:DECLARES]-(caller)
MATCH (caller)-[:INVOKES_REMOTE]->(calledEndpoint)
MATCH (calledEndpoint)<-[:DECLARES]-(calledClass:Class)<-[:CONTAINS]-(calledService:Artifact)
RETURN *
To find out cross service dependency chains
© 2019 GraphAware Ltd. All rights reserved.
Microservices or distributed monolith ?
source: martinfowler.com
© 2019 GraphAware Ltd. All rights reserved.
Data governance
Are my services (over)sharing data?
MATCH (jar:Artifact)--(entity:Type)-[:ANNOTATED_BY]->(ann:Annotation)
MATCH (ann)-[:OF_TYPE]-(:Type{fqn:'org.springframework.data.mongodb.core.mapping.Document'})
MATCH (ann)-[:HAS]->(collection:Value{name:"collection"})
SET entity:Entity:MongoDb
SET entity.collectionName=collection.value
RETURN entity.fqn as class, entity.collectionName as collection, jar.serviceName as usedBy
ORDER by collection
[ ]
Needs to be
investigated
© 2019 GraphAware Ltd. All rights reserved.
More impact analysis
What’s the impact on endpoints of changing XYZ?
MATCH p=(ep:Endpoint)-[:INVOKES|VIRTUAL_INVOKES|INVOKES_REMOTE*]->(m)<--(r:Repository)
RETURN r.name, m.signature, collect(ep.method +' '+ ep.fullUrl) as usedBy
ORDER BY r.name
© 2019 GraphAware Ltd. All rights reserved.
Is the documentation up to date?
openapi: 3.0.1
info:
title: Piggy bank sample app
description: 'a sample documentation for the statistics service'
version: 1.0.0
tags:
- name: statistics
description: Statistics service
paths:
/statistics/{accountName}:
put:
tags:
- statistics
summary: Update account stats
operationId: saveAccountStatistics
parameters:
- name: accountName
in: path
description: Name of the account to update
required: true
schema:
type: string
requestBody:
description: Account object that needs to be added to the store
content:
application/json:
schema:
$ref: '#/components/schemas/Account'
required: true
MATCH (a:Artifact)
OPTIONAL MATCH (a)-[:CONTAINS]->(f:File)
--(doc:Document:YAML)--(key:Key{name:'openapi'})
RETURN distinct a.serviceName, f.fileName
© 2019 GraphAware Ltd. All rights reserved.
Is the documentation up to date?
Code
Vs
ApiDoc
© 2019 GraphAware Ltd. All rights reserved.
What about resilience?
MATCH (client:Interface)-[:ANNOTATED_BY]->(a)-[:OF_TYPE]->
(t:Type{fqn:”org.springframework.cloud.openfeign.FeignClient”})
OPTIONAL MATCH (a)-[:HAS]-(v:Value{name:'fallback'})--(fb:Type)
RETURN client.fqn as client, fb.fqn as fallback
© 2019 GraphAware Ltd. All rights reserved.
Knowledge sharing
GraphML export => Visualisation tool
© 2019 GraphAware Ltd. All rights reserved.
Knowledge sharing
© 2019 GraphAware Ltd. All rights reserved.
A lot more to explore!
• Security
• What needs to be tested ?
• Runtime data
• SCM data
• Graph algos
• Front end code scanning
• Evolution over time
• …
Photo by Gaetano Cessati on Unsplash
© 2019 GraphAware Ltd. All rights reserved.
Give it a try!
Code examples on
https://github.com/graphaware/fix-your-microservicesjQAssistant.org
© 2019 GraphAware Ltd. All rights reserved.
Thank you
For more information please contact:
Nicolas Mervaillie · 10/10/2019

info@graphaware.com.
@nmervaillie
graphaware.com
© 2019 GraphAware Ltd. All rights reserved.
Hunger Games Questions for
"Fix your microservice architecture using graph analysis"
1.Easy: jQAssistant is able to scan:

1.JVM byte code
2.JSON / YAML / properties files
3.All of them, and more

2.Medium: How many plugins are available jQA?

1.Less than 10
2.Between 10 and 30
3.More than 30

3.Hard: What is the API documentation format used in the examples?

Answer here: r.neo4j.com/hunger-games

Weitere ähnliche Inhalte

Mehr von GraphAware

Signals from outer space
Signals from outer spaceSignals from outer space
Signals from outer spaceGraphAware
 
Neo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4jNeo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4jGraphAware
 
Graph-Powered Machine Learning
Graph-Powered Machine Learning Graph-Powered Machine Learning
Graph-Powered Machine Learning GraphAware
 
(Big) Data Science
 (Big) Data Science (Big) Data Science
(Big) Data ScienceGraphAware
 
Modelling Data in Neo4j (plus a few tips)
Modelling Data in Neo4j (plus a few tips)Modelling Data in Neo4j (plus a few tips)
Modelling Data in Neo4j (plus a few tips)GraphAware
 
Intro to Neo4j (CZ)
Intro to Neo4j (CZ)Intro to Neo4j (CZ)
Intro to Neo4j (CZ)GraphAware
 
Modelling Data as Graphs (Neo4j)
Modelling Data as Graphs (Neo4j)Modelling Data as Graphs (Neo4j)
Modelling Data as Graphs (Neo4j)GraphAware
 
GraphAware Framework Intro
GraphAware Framework IntroGraphAware Framework Intro
GraphAware Framework IntroGraphAware
 
Advanced Neo4j Use Cases with the GraphAware Framework
Advanced Neo4j Use Cases with the GraphAware FrameworkAdvanced Neo4j Use Cases with the GraphAware Framework
Advanced Neo4j Use Cases with the GraphAware FrameworkGraphAware
 
Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)GraphAware
 
Machine Learning Powered by Graphs - Alessandro Negro
Machine Learning Powered by Graphs - Alessandro NegroMachine Learning Powered by Graphs - Alessandro Negro
Machine Learning Powered by Graphs - Alessandro NegroGraphAware
 
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe Willemsen
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe WillemsenKnowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe Willemsen
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe WillemsenGraphAware
 
The power of polyglot searching
The power of polyglot searchingThe power of polyglot searching
The power of polyglot searchingGraphAware
 
Neo4j-Databridge
Neo4j-DatabridgeNeo4j-Databridge
Neo4j-DatabridgeGraphAware
 
Spring Data Neo4j: Graph Power Your Enterprise Apps
Spring Data Neo4j: Graph Power Your Enterprise AppsSpring Data Neo4j: Graph Power Your Enterprise Apps
Spring Data Neo4j: Graph Power Your Enterprise AppsGraphAware
 
Voice-driven Knowledge Graph Journey with Neo4j and Amazon Alexa
Voice-driven Knowledge Graph Journey with Neo4j and Amazon AlexaVoice-driven Knowledge Graph Journey with Neo4j and Amazon Alexa
Voice-driven Knowledge Graph Journey with Neo4j and Amazon AlexaGraphAware
 
Graph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with GraphgenGraph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with GraphgenGraphAware
 
Relevant Search Leveraging Knowledge Graphs with Neo4j
Relevant Search Leveraging Knowledge Graphs with Neo4jRelevant Search Leveraging Knowledge Graphs with Neo4j
Relevant Search Leveraging Knowledge Graphs with Neo4jGraphAware
 
Real-Time Recommendations and the Future of Search
Real-Time Recommendations and the Future of SearchReal-Time Recommendations and the Future of Search
Real-Time Recommendations and the Future of SearchGraphAware
 
Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4GraphAware
 

Mehr von GraphAware (20)

Signals from outer space
Signals from outer spaceSignals from outer space
Signals from outer space
 
Neo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4jNeo4j-Databridge: Enterprise-scale ETL for Neo4j
Neo4j-Databridge: Enterprise-scale ETL for Neo4j
 
Graph-Powered Machine Learning
Graph-Powered Machine Learning Graph-Powered Machine Learning
Graph-Powered Machine Learning
 
(Big) Data Science
 (Big) Data Science (Big) Data Science
(Big) Data Science
 
Modelling Data in Neo4j (plus a few tips)
Modelling Data in Neo4j (plus a few tips)Modelling Data in Neo4j (plus a few tips)
Modelling Data in Neo4j (plus a few tips)
 
Intro to Neo4j (CZ)
Intro to Neo4j (CZ)Intro to Neo4j (CZ)
Intro to Neo4j (CZ)
 
Modelling Data as Graphs (Neo4j)
Modelling Data as Graphs (Neo4j)Modelling Data as Graphs (Neo4j)
Modelling Data as Graphs (Neo4j)
 
GraphAware Framework Intro
GraphAware Framework IntroGraphAware Framework Intro
GraphAware Framework Intro
 
Advanced Neo4j Use Cases with the GraphAware Framework
Advanced Neo4j Use Cases with the GraphAware FrameworkAdvanced Neo4j Use Cases with the GraphAware Framework
Advanced Neo4j Use Cases with the GraphAware Framework
 
Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)Recommendations with Neo4j (FOSDEM 2015)
Recommendations with Neo4j (FOSDEM 2015)
 
Machine Learning Powered by Graphs - Alessandro Negro
Machine Learning Powered by Graphs - Alessandro NegroMachine Learning Powered by Graphs - Alessandro Negro
Machine Learning Powered by Graphs - Alessandro Negro
 
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe Willemsen
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe WillemsenKnowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe Willemsen
Knowledge Graphs and Chatbots with Neo4j and IBM Watson - Christophe Willemsen
 
The power of polyglot searching
The power of polyglot searchingThe power of polyglot searching
The power of polyglot searching
 
Neo4j-Databridge
Neo4j-DatabridgeNeo4j-Databridge
Neo4j-Databridge
 
Spring Data Neo4j: Graph Power Your Enterprise Apps
Spring Data Neo4j: Graph Power Your Enterprise AppsSpring Data Neo4j: Graph Power Your Enterprise Apps
Spring Data Neo4j: Graph Power Your Enterprise Apps
 
Voice-driven Knowledge Graph Journey with Neo4j and Amazon Alexa
Voice-driven Knowledge Graph Journey with Neo4j and Amazon AlexaVoice-driven Knowledge Graph Journey with Neo4j and Amazon Alexa
Voice-driven Knowledge Graph Journey with Neo4j and Amazon Alexa
 
Graph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with GraphgenGraph Database Prototyping made easy with Graphgen
Graph Database Prototyping made easy with Graphgen
 
Relevant Search Leveraging Knowledge Graphs with Neo4j
Relevant Search Leveraging Knowledge Graphs with Neo4jRelevant Search Leveraging Knowledge Graphs with Neo4j
Relevant Search Leveraging Knowledge Graphs with Neo4j
 
Real-Time Recommendations and the Future of Search
Real-Time Recommendations and the Future of SearchReal-Time Recommendations and the Future of Search
Real-Time Recommendations and the Future of Search
 
Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4Webinar about Spring Data Neo4j 4
Webinar about Spring Data Neo4j 4
 

Kürzlich hochgeladen

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 

Kürzlich hochgeladen (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 

Fix your microservice architecture using graph analysis

  • 1. © 2019 GraphAware Ltd. All rights reserved. Fix your microservice architecture Using graph analysis Nicolas Mervaillie - Principal Consultant @ GraphAware graphaware.com @graph_aware, @nmervaillie #neo4j and #jQAssistant
  • 2. © 2019 GraphAware Ltd. All rights reserved. @nmervaillie https://www.linkedin.com/in/nicolas-mervaillie-a2b9876/
  • 3. © 2019 GraphAware Ltd. All rights reserved. Microservices…. theory vs reality Photo by Alphacolor on Unsplash Photo by Rick Mason on Unsplash
  • 4. © 2019 GraphAware Ltd. All rights reserved. Not everyone is etfli or Photo by Tommy Lisbin on Unsplash
  • 5. © 2019 GraphAware Ltd. All rights reserved. Code is a Graph! • Detect anti-patterns • Impact analysis • Better data governance • Improve communication between teams
  • 6. © 2019 GraphAware Ltd. All rights reserved. Let’s try on an example application https://github.com/sqshq/PiggyMetrics ./jqassistant.sh scan -f PiggyMetrics/account-service/target/account-service.jar, PiggyMetrics/auth-service/target/auth-service.jar, PiggyMetrics/notification-service/target/notification-service.jar, PiggyMetrics/statistics-service/target/statistics-service.jar, PiggyMetrics/config/target/config.jar
  • 7. © 2019 GraphAware Ltd. All rights reserved. @RestController @RequestMapping("/users") public class UserController { @Autowired private UserService userService; @RequestMapping(value = "/current", method = RequestMethod.GET) public Principal getUser(Principal principal) { return principal; } @PreAuthorize("#oauth2.hasScope('server')") @RequestMapping(method = RequestMethod.POST) public void createUser(@Valid @RequestBody User user) { userService.create(user); } } How does this translate into a graph ?
  • 8. © 2019 GraphAware Ltd. All rights reserved.
  • 9. © 2019 GraphAware Ltd. All rights reserved. We can define higher level concepts • APIs • Software architecture • Engineering practices • … OK, but what about my loosely coupled microservices? Photo by ⻉贝莉⼉儿 NG on Unsplash
  • 10. © 2019 GraphAware Ltd. All rights reserved. REST Endpoints MATCH (cls:Class)-[:DECLARES]->(endpoint)-[:ANNOTATED_BY]->(ann:Annotation)-[:OF_TYPE]->(:Type{name:"RequestMapping"}) WHERE cls.fqn starts with 'com.' OPTIONAL MATCH (ann)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value) OPTIONAL MATCH (ann)-[:HAS]->(:Value{name:"method"})-[:CONTAINS]->()-[:IS]->(httpMethod:Field) SET endpoint:Endpoint SET endpoint.method = split(httpMethod.signature, " ")[1] SET endpoint.url = url.value RETURN cls.fqn, endpoint.url, endpoint.method @RequestMapping Annotation HTTP
 url/method
  • 11. © 2019 GraphAware Ltd. All rights reserved. Feign (HTTP) clients MATCH (client:Interface)-[:DECLARES]->(m:Method) WHERE client.fqn STARTS WITH "com." AND (client)-[:ANNOTATED_BY]->()-[:OF_TYPE]->(:Type{fqn:"org.springframework.cloud.openfeign.FeignClient"}) MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:HAS]->(:Value{name:"value"})-[:CONTAINS]->(url:Value) MATCH (m)-[:ANNOTATED_BY]->(ann:Annotation)-[:HAS]->(:Value{name:"method"})-[:CONTAINS]->()-[:IS]- >(httpMethod:Field) SET m:FeignClient SET m.url = apoc.text.regreplace(url.value, '{.*}', '{}') SET m.httpMethod = split(httpMethod.signature, ' ')[1] return m.name, m.httpMethod, m.url
  • 12. © 2019 GraphAware Ltd. All rights reserved. To materialize HTTP calls in the graph MATCH (client:FeignClient), (endpoint:Endpoint) WHERE client.url=endpoint.fullUrl and client.httpMethod=endpoint.method MERGE (client)-[:INVOKES_REMOTE]->(endpoint) RETURN client, endpoint
  • 13. © 2019 GraphAware Ltd. All rights reserved. MATCH (callerService:Artifact)-[:CONTAINS]-(callerClass:Type)-[:DECLARES]-(caller) MATCH (caller)-[:INVOKES_REMOTE]->(calledEndpoint) MATCH (calledEndpoint)<-[:DECLARES]-(calledClass:Class)<-[:CONTAINS]-(calledService:Artifact) RETURN * To find out cross service dependency chains
  • 14. © 2019 GraphAware Ltd. All rights reserved. Microservices or distributed monolith ? source: martinfowler.com
  • 15. © 2019 GraphAware Ltd. All rights reserved. Data governance Are my services (over)sharing data? MATCH (jar:Artifact)--(entity:Type)-[:ANNOTATED_BY]->(ann:Annotation) MATCH (ann)-[:OF_TYPE]-(:Type{fqn:'org.springframework.data.mongodb.core.mapping.Document'}) MATCH (ann)-[:HAS]->(collection:Value{name:"collection"}) SET entity:Entity:MongoDb SET entity.collectionName=collection.value RETURN entity.fqn as class, entity.collectionName as collection, jar.serviceName as usedBy ORDER by collection [ ] Needs to be investigated
  • 16. © 2019 GraphAware Ltd. All rights reserved. More impact analysis What’s the impact on endpoints of changing XYZ? MATCH p=(ep:Endpoint)-[:INVOKES|VIRTUAL_INVOKES|INVOKES_REMOTE*]->(m)<--(r:Repository) RETURN r.name, m.signature, collect(ep.method +' '+ ep.fullUrl) as usedBy ORDER BY r.name
  • 17. © 2019 GraphAware Ltd. All rights reserved. Is the documentation up to date? openapi: 3.0.1 info: title: Piggy bank sample app description: 'a sample documentation for the statistics service' version: 1.0.0 tags: - name: statistics description: Statistics service paths: /statistics/{accountName}: put: tags: - statistics summary: Update account stats operationId: saveAccountStatistics parameters: - name: accountName in: path description: Name of the account to update required: true schema: type: string requestBody: description: Account object that needs to be added to the store content: application/json: schema: $ref: '#/components/schemas/Account' required: true MATCH (a:Artifact) OPTIONAL MATCH (a)-[:CONTAINS]->(f:File) --(doc:Document:YAML)--(key:Key{name:'openapi'}) RETURN distinct a.serviceName, f.fileName
  • 18. © 2019 GraphAware Ltd. All rights reserved. Is the documentation up to date? Code Vs ApiDoc
  • 19. © 2019 GraphAware Ltd. All rights reserved. What about resilience? MATCH (client:Interface)-[:ANNOTATED_BY]->(a)-[:OF_TYPE]-> (t:Type{fqn:”org.springframework.cloud.openfeign.FeignClient”}) OPTIONAL MATCH (a)-[:HAS]-(v:Value{name:'fallback'})--(fb:Type) RETURN client.fqn as client, fb.fqn as fallback
  • 20. © 2019 GraphAware Ltd. All rights reserved. Knowledge sharing GraphML export => Visualisation tool
  • 21. © 2019 GraphAware Ltd. All rights reserved. Knowledge sharing
  • 22. © 2019 GraphAware Ltd. All rights reserved. A lot more to explore! • Security • What needs to be tested ? • Runtime data • SCM data • Graph algos • Front end code scanning • Evolution over time • … Photo by Gaetano Cessati on Unsplash
  • 23. © 2019 GraphAware Ltd. All rights reserved. Give it a try! Code examples on https://github.com/graphaware/fix-your-microservicesjQAssistant.org
  • 24. © 2019 GraphAware Ltd. All rights reserved. Thank you For more information please contact: Nicolas Mervaillie · 10/10/2019
 info@graphaware.com. @nmervaillie graphaware.com
  • 25. © 2019 GraphAware Ltd. All rights reserved. Hunger Games Questions for "Fix your microservice architecture using graph analysis" 1.Easy: jQAssistant is able to scan:
 1.JVM byte code 2.JSON / YAML / properties files 3.All of them, and more
 2.Medium: How many plugins are available jQA?
 1.Less than 10 2.Between 10 and 30 3.More than 30
 3.Hard: What is the API documentation format used in the examples?
 Answer here: r.neo4j.com/hunger-games