SlideShare ist ein Scribd-Unternehmen logo
1 von 54
19 millions searches per day @ Meetic
A search engine in a world of events and microservices
Me and myself
@seb_legall
Tech Lead back-end @ Meetic
Started in 2001
•
Active in 15 countries
•
Dating leader in Europe
•
Millions of Monthly Active Users
•
150 people in IT teams
Meetic Before
Webservices
Backoffices
Mobile Web
WAP
Desktop
Cronjobs
…
Exposition Layer
Event bus
Consumers
Micro-services
BackOffices
Meetic Now
John and Ygritte, a game of
microservices
Code is coming.
Once upon a time in a far far away galaxy
country…
John wants to meet someone Ygritte wants to meet someone
Ygritte knows what king of John she wants
Ygritte knows what she wants for her.
She is looking for a John that match with her criterias.
$ curl –XGET https://api.meetic.fr/search?height=188&eyes=brown&region=north&country=westeros
John knows nothing
John is looking for love, wherever it comes from.
(Except from Casterly Rock)
$ curl –XGET https://api.meetic.fr/search/1234/shuffle
John’s Id
Summary
• Let’s introduce the search microservice
• An overview of the code architecture in a microservice
• Indexing data
• What happens when Ygritte update her profile?
• John signs up on Meetic. How his profile is indexed?
• Searching people
• Overview of the advanced search feature used by Ygritte
• How does Meetic suggest profile that may interest John?
Introducing the search
microservice
It says “search”. Not necessarily “find”.
The search microservice
The search microservice has one responsibility and only one :
Searching Meetic users
Some Meetic features :
• Advanced Search
• Shuffle (Tinder like)
• Online profiles
• Similar Profiles
• Etc..
The search microservice
In order to do so, the search microservice should :
• Be responsible of the way data is stored
• Be aware of any data updates when the updates are in its scope
• Return a list of profile’s ID when calling it
The search microservice Event bus
Consumer
Search
Exposition Layer
Indexing data
About code structure in a
microservice @ Meetic
Don’t blame your messy code, blame the design pattern.
(or the architect, or the tech lead, or the product owner)
The hexagonal workflow
Request (GET)
Handler
DAO
Domain Object
Domain
Repository
Populate
Call
Implements
Infrastructure
Application
Domain
Design pattern hexagonal
Domain management
Infrastructure implementation
(repositories)
Request management
Design pattern hexagonal
Define the “profile” domain object
Implement the repository using Guzzle
Handle the “search” request
Define how profile should be get
Implement the repository using Doctrine
Ygritte
…already has an account on Meetic
Ygritte updates her Meetic Profile
Event bus
Consumer
Picture
Exposition Layer
PUT
{
”id”: 6789,
“picture”: “me.jpg”
}
PUT
{
”id”: 6789,
“picture”: “me.jpg”
}
UPSERT
{
”id”: 6789,
“has_photo”: true
}
John
…have just discovered Meetic. He wants to sign up.
John signs up on Meetic
(What should be done)
Event bus
Consumer
Profile
Exposition Layer
POST
{
”id”: 1234,
“birthday”: “1989-01-12,
”picture”: “me.jpg”
}
POST
{
”id”: 1234,
“birthday”: “1989-01-12
}
POST
{
”id”: 6789,
“birthday”: “1989-01-12,
“has_photo”: true,
“paymentStatus”: “free”,
….
}
GET /1234/pictures
GET /payment-status/1234
GET …
Picture
POST
{
”id”: 1234,
“picture”: “me.jpg”
}
Theory vs reality
Calling microservices
+ In case of change on any databases, this workflow stay unchanged
+ Avoid duplicated business logic
- Don’t scale very well because of the number of http calls needed
- Takes a lot of time to implement
John signs up on Meetic
(What is really done)
Event bus
Consumer
Profile
Exposition Layer
POST
{
”id”: 1234,
“birthday”: “1989-01-12
}
POST /reload/6789
Search
SELECT * FROM PROFILE
LEFT JOIN PAYMENT
WHERE ID = 1234POST
{
”id”: 1234,
“birthday”: “1989-01-12,
“eye”: “brown”,
“paymentStatus”: “free”,
….
}
Picture
POST
{
”id”: 1234,
“birthday”: “1989-01-12,
”picture”: “me.jpg”
}
POST
{
”id”: 1234,
“picture”: “me.jpg”
}
Theory vs reality
Querying the database
+ The search microservice stays responsible of his data
+ Allows batch processing
- Works only because databases are not yet split
- Change on the database have to be replicated in the search
microservice
Managing big (SQL) queries
with Symfony
… using the compiler pass
What does the reload query looks
like?
SELECT
ID,
BIRTHDAY,
…,
(SELECT * FROM …),
FROM MEETIC.MEMBER
INNER JOIN …
LEFT JOIN…
INNER JOIN…
LEFT JOIN…
LEFT JOIN…
INNER JOIN…
WHERE (
SELECT T FROM MEETIC.T WHERE …
)
AND …
OR…
Keeping the reload query maintainable
Since we chose to get data directly from the database when creating a
new document in the index, the SQL query is huge and complex.
• We need it to be easily shared, review and updated by DBAs
• We need to keep it isolated so changes in the DB schema can be
reported in a single file
• We want to be able to just copy-paste it and check if it works.
Managing big (SQL) queries with Symfony
#1 Step : The
application handle the
request by calling the
domain interface
Managing big (SQL) queries with Symfony
#2 Step : The
domain describe
how objects
should be
manipulated
Managing big (SQL) queries with Symfony
#3 Step : The
infrastructure actually
manipulate data.
Injecting resources at compile time
Service declaration :
Injecting resources at compile time
We use the Symfony CompilerPass to
inject a file content as a string in the
DAO.
Searching data
Ygritte
is using the search engine
Ygritte uses the search engine
Exposition Layer
Search
POST
{
“query”: {
“term”: {
”eyes”: “brown”
}
}
}
GET /search?eye=brown&hair=brown
GET /search?eye=brown&hair=brown
{
”memberId”: [
1234,
456786,
]
}
Keeping the search logic clear
Templating ElasticSearch queries with twig
What does an ElasticSearch
query look like?
Most of the time the ElasticSearch query contains the larger
part of the business logic.
• Very long
• Lot of strange json key
• Lot of parameters
And yet…
Why not generating queries via php?
• Managing big PHP array throw if…else is quite hard
• It becomes harder to understand what actually
does the query.
Keeping the
business logic clear
with twig
Templating the json query using
twig let us know easily what
actually does the query
Keeping the business logic clear with twig
Injecting parameters
become easier.
John
is using the shuffle feature
John uses the shuffle
Exposition Layer
Search
POST
{
“query”: {
”must”: {
“term”: {
”eyes”: “brown”
}
},
“must_not”: {
”terms”: {
”id”: [876,4567]
}
}
}
GET /search/1234/shuffle
GET /search/1234/shuffle
{
”memberId”: [
5678,
09876,
]
}
GET /interaction/1234/black-list
GET /referential/1234/search
Building ElasticSearch query
from multiple source
…using the Guzzle promises
Building query from multiple source
Request (GET)
Handler
Enricher
Domain Object
Domain
Repository
Populate
Call
Implements
Infrastructure
Application
Domain
DAO DAO
DAO
Optimizing response time with Guzzle promises
Http calls take time.
Guzzle promises let us use
parallelism in order to save
precious milliseconds.
Optimizing with Guzzle promises
1
2
3
4
5
6
1
2
3
4
5
6
Calls
Time
Conclusion
Is that all theoretical or is it actually working in production?
Search microservice in production
• 19 millions hits per day
• ~ 10 servers on 2 DC needed to be “Disaster Recovery Plan” friendly
• Search route AVG response time : ~ 163 ms
• Shuffle route AVG response time : ~ 336 ms
Elasticsearch in production
Any questions?

Weitere ähnliche Inhalte

Was ist angesagt?

Or2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflowOr2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflow4Science
 
Overview of new features in Apache Ranger
Overview of new features in Apache RangerOverview of new features in Apache Ranger
Overview of new features in Apache RangerDataWorks Summit
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General IntroductionAsma CHERIF
 
Introduction to AWS Glue: Data Analytics Week at the SF Loft
Introduction to AWS Glue: Data Analytics Week at the SF LoftIntroduction to AWS Glue: Data Analytics Week at the SF Loft
Introduction to AWS Glue: Data Analytics Week at the SF LoftAmazon Web Services
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan GoleChetan Gole
 
DSpace Training Presentation
DSpace Training PresentationDSpace Training Presentation
DSpace Training PresentationThomas King
 
MODAF- Ministry of Defence Architecture Framework
MODAF- Ministry of Defence Architecture FrameworkMODAF- Ministry of Defence Architecture Framework
MODAF- Ministry of Defence Architecture FrameworkQuinnipiac University
 
Schema-on-Read vs Schema-on-Write
Schema-on-Read vs Schema-on-WriteSchema-on-Read vs Schema-on-Write
Schema-on-Read vs Schema-on-WriteAmr Awadallah
 
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017Amazon Web Services Korea
 
The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)Myungjin Lee
 
Consuming RealTime Signals in Solr
Consuming RealTime Signals in Solr Consuming RealTime Signals in Solr
Consuming RealTime Signals in Solr Umesh Prasad
 
Sa 006 modifiability
Sa 006 modifiabilitySa 006 modifiability
Sa 006 modifiabilityFrank Gielen
 
Data Warehousing & Basic Architectural Framework
Data Warehousing & Basic Architectural FrameworkData Warehousing & Basic Architectural Framework
Data Warehousing & Basic Architectural FrameworkDr. Sunil Kr. Pandey
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...jexp
 
Module 2 - Datalake
Module 2 - DatalakeModule 2 - Datalake
Module 2 - DatalakeLam Le
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software EngineeringManish Kumar
 
Knowledge Representation, Semantic Web
Knowledge Representation, Semantic WebKnowledge Representation, Semantic Web
Knowledge Representation, Semantic WebSerendipity Seraph
 

Was ist angesagt? (20)

Or2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflowOr2019 DSpace 7 Enhanced submission & workflow
Or2019 DSpace 7 Enhanced submission & workflow
 
Overview of new features in Apache Ranger
Overview of new features in Apache RangerOverview of new features in Apache Ranger
Overview of new features in Apache Ranger
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Introduction to AWS Glue: Data Analytics Week at the SF Loft
Introduction to AWS Glue: Data Analytics Week at the SF LoftIntroduction to AWS Glue: Data Analytics Week at the SF Loft
Introduction to AWS Glue: Data Analytics Week at the SF Loft
 
Design Patterns Presentation - Chetan Gole
Design Patterns Presentation -  Chetan GoleDesign Patterns Presentation -  Chetan Gole
Design Patterns Presentation - Chetan Gole
 
DSpace Training Presentation
DSpace Training PresentationDSpace Training Presentation
DSpace Training Presentation
 
MODAF- Ministry of Defence Architecture Framework
MODAF- Ministry of Defence Architecture FrameworkMODAF- Ministry of Defence Architecture Framework
MODAF- Ministry of Defence Architecture Framework
 
Schema-on-Read vs Schema-on-Write
Schema-on-Read vs Schema-on-WriteSchema-on-Read vs Schema-on-Write
Schema-on-Read vs Schema-on-Write
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Inroduction to Dspace
Inroduction to DspaceInroduction to Dspace
Inroduction to Dspace
 
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017
Amazon EMR 고급 활용 기법 - AWS Summit Seoul 2017
 
The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)The Semantic Web #9 - Web Ontology Language (OWL)
The Semantic Web #9 - Web Ontology Language (OWL)
 
Consuming RealTime Signals in Solr
Consuming RealTime Signals in Solr Consuming RealTime Signals in Solr
Consuming RealTime Signals in Solr
 
Sa 006 modifiability
Sa 006 modifiabilitySa 006 modifiability
Sa 006 modifiability
 
Data Warehousing & Basic Architectural Framework
Data Warehousing & Basic Architectural FrameworkData Warehousing & Basic Architectural Framework
Data Warehousing & Basic Architectural Framework
 
How Graph Databases efficiently store, manage and query connected data at s...
How Graph Databases efficiently  store, manage and query  connected data at s...How Graph Databases efficiently  store, manage and query  connected data at s...
How Graph Databases efficiently store, manage and query connected data at s...
 
Module 2 - Datalake
Module 2 - DatalakeModule 2 - Datalake
Module 2 - Datalake
 
Semantic search
Semantic searchSemantic search
Semantic search
 
Design Pattern in Software Engineering
Design Pattern in Software EngineeringDesign Pattern in Software Engineering
Design Pattern in Software Engineering
 
Knowledge Representation, Semantic Web
Knowledge Representation, Semantic WebKnowledge Representation, Semantic Web
Knowledge Representation, Semantic Web
 

Ähnlich wie A search engine in a world of events and microservices - SF Pot @Meetic

Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015StampedeCon
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use CasesMax De Marzi
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2Neo4j
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016DataStax
 
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...Connected Data World
 
Introduction: Relational to Graphs
Introduction: Relational to GraphsIntroduction: Relational to Graphs
Introduction: Relational to GraphsNeo4j
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and PythonTravis Oliphant
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchMongoDB
 
Elasticsearch : petit déjeuner du 13 mars 2014
Elasticsearch : petit déjeuner du 13 mars 2014Elasticsearch : petit déjeuner du 13 mars 2014
Elasticsearch : petit déjeuner du 13 mars 2014ALTER WAY
 
A whirlwind tour of graph databases
A whirlwind tour of graph databasesA whirlwind tour of graph databases
A whirlwind tour of graph databasesjexp
 
Making Sense of Schema on Read
Making Sense of Schema on ReadMaking Sense of Schema on Read
Making Sense of Schema on ReadKent Graziano
 
Data Modelling Zone 2019 - data modelling and JSON
Data Modelling Zone 2019 - data modelling and JSONData Modelling Zone 2019 - data modelling and JSON
Data Modelling Zone 2019 - data modelling and JSONGeorge McGeachie
 
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Neo4j
 
How Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and AnalyticsHow Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and Analyticsmattinsler
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeWim Godden
 
213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.keyNAVER D2
 
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014Séminaire Big Data Alter Way - Elasticsearch - octobre 2014
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014ALTER WAY
 
There and Back Again, A Developer's Tale
There and Back Again, A Developer's TaleThere and Back Again, A Developer's Tale
There and Back Again, A Developer's TaleNeo4j
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchMongoDB
 

Ähnlich wie A search engine in a world of events and microservices - SF Pot @Meetic (20)

Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015Graph Database Use Cases - StampedeCon 2015
Graph Database Use Cases - StampedeCon 2015
 
Graph database Use Cases
Graph database Use CasesGraph database Use Cases
Graph database Use Cases
 
Graphs fun vjug2
Graphs fun vjug2Graphs fun vjug2
Graphs fun vjug2
 
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
C* for Deep Learning (Andrew Jefferson, Tracktable) | Cassandra Summit 2016
 
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...
From Knowledge Graphs to AI-powered SEO: Using taxonomies, schemas and knowle...
 
Neo4j in Depth
Neo4j in DepthNeo4j in Depth
Neo4j in Depth
 
Introduction: Relational to Graphs
Introduction: Relational to GraphsIntroduction: Relational to Graphs
Introduction: Relational to Graphs
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and Python
 
Building Your First App with MongoDB Stitch
Building Your First App with MongoDB StitchBuilding Your First App with MongoDB Stitch
Building Your First App with MongoDB Stitch
 
Elasticsearch : petit déjeuner du 13 mars 2014
Elasticsearch : petit déjeuner du 13 mars 2014Elasticsearch : petit déjeuner du 13 mars 2014
Elasticsearch : petit déjeuner du 13 mars 2014
 
A whirlwind tour of graph databases
A whirlwind tour of graph databasesA whirlwind tour of graph databases
A whirlwind tour of graph databases
 
Making Sense of Schema on Read
Making Sense of Schema on ReadMaking Sense of Schema on Read
Making Sense of Schema on Read
 
Data Modelling Zone 2019 - data modelling and JSON
Data Modelling Zone 2019 - data modelling and JSONData Modelling Zone 2019 - data modelling and JSON
Data Modelling Zone 2019 - data modelling and JSON
 
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
Graphs & Big Data - Philip Rathle and Andreas Kollegger @ Big Data Science Me...
 
How Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and AnalyticsHow Signpost uses MongoDB for Tracking and Analytics
How Signpost uses MongoDB for Tracking and Analytics
 
Beyond php - it's not (just) about the code
Beyond php - it's not (just) about the codeBeyond php - it's not (just) about the code
Beyond php - it's not (just) about the code
 
213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key213 event processingtalk-deviewkorea.key
213 event processingtalk-deviewkorea.key
 
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014Séminaire Big Data Alter Way - Elasticsearch - octobre 2014
Séminaire Big Data Alter Way - Elasticsearch - octobre 2014
 
There and Back Again, A Developer's Tale
There and Back Again, A Developer's TaleThere and Back Again, A Developer's Tale
There and Back Again, A Developer's Tale
 
Tutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB StitchTutorial: Building Your First App with MongoDB Stitch
Tutorial: Building Your First App with MongoDB Stitch
 

Mehr von meeticTech

REX Meetic, Comment la qualité reflète-t-elle nos organisations ?
REX Meetic, Comment la qualité reflète-t-elle nos organisations ?REX Meetic, Comment la qualité reflète-t-elle nos organisations ?
REX Meetic, Comment la qualité reflète-t-elle nos organisations ?meeticTech
 
iOS App Group for Debugging
iOS App Group for DebuggingiOS App Group for Debugging
iOS App Group for DebuggingmeeticTech
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechmeeticTech
 
Meetup scala paris user group - conflation like @ meetic
Meetup scala paris user group - conflation like @ meeticMeetup scala paris user group - conflation like @ meetic
Meetup scala paris user group - conflation like @ meeticmeeticTech
 
Paris Job Talk
Paris Job TalkParis Job Talk
Paris Job TalkmeeticTech
 
Transition Agile @ Meetic
Transition Agile @ MeeticTransition Agile @ Meetic
Transition Agile @ MeeticmeeticTech
 
Meetic Backend Mutation With Symfony
Meetic Backend Mutation With SymfonyMeetic Backend Mutation With Symfony
Meetic Backend Mutation With SymfonymeeticTech
 

Mehr von meeticTech (7)

REX Meetic, Comment la qualité reflète-t-elle nos organisations ?
REX Meetic, Comment la qualité reflète-t-elle nos organisations ?REX Meetic, Comment la qualité reflète-t-elle nos organisations ?
REX Meetic, Comment la qualité reflète-t-elle nos organisations ?
 
iOS App Group for Debugging
iOS App Group for DebuggingiOS App Group for Debugging
iOS App Group for Debugging
 
PHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTechPHP Symfony MicroServices Migration @MeeticTech
PHP Symfony MicroServices Migration @MeeticTech
 
Meetup scala paris user group - conflation like @ meetic
Meetup scala paris user group - conflation like @ meeticMeetup scala paris user group - conflation like @ meetic
Meetup scala paris user group - conflation like @ meetic
 
Paris Job Talk
Paris Job TalkParis Job Talk
Paris Job Talk
 
Transition Agile @ Meetic
Transition Agile @ MeeticTransition Agile @ Meetic
Transition Agile @ Meetic
 
Meetic Backend Mutation With Symfony
Meetic Backend Mutation With SymfonyMeetic Backend Mutation With Symfony
Meetic Backend Mutation With Symfony
 

Kürzlich hochgeladen

chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdfKamal Acharya
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Kürzlich hochgeladen (20)

(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

A search engine in a world of events and microservices - SF Pot @Meetic

  • 1. 19 millions searches per day @ Meetic A search engine in a world of events and microservices
  • 2. Me and myself @seb_legall Tech Lead back-end @ Meetic
  • 3. Started in 2001 • Active in 15 countries • Dating leader in Europe • Millions of Monthly Active Users • 150 people in IT teams
  • 6. John and Ygritte, a game of microservices Code is coming.
  • 7. Once upon a time in a far far away galaxy country… John wants to meet someone Ygritte wants to meet someone
  • 8. Ygritte knows what king of John she wants Ygritte knows what she wants for her. She is looking for a John that match with her criterias. $ curl –XGET https://api.meetic.fr/search?height=188&eyes=brown&region=north&country=westeros
  • 9. John knows nothing John is looking for love, wherever it comes from. (Except from Casterly Rock) $ curl –XGET https://api.meetic.fr/search/1234/shuffle John’s Id
  • 10. Summary • Let’s introduce the search microservice • An overview of the code architecture in a microservice • Indexing data • What happens when Ygritte update her profile? • John signs up on Meetic. How his profile is indexed? • Searching people • Overview of the advanced search feature used by Ygritte • How does Meetic suggest profile that may interest John?
  • 11. Introducing the search microservice It says “search”. Not necessarily “find”.
  • 12. The search microservice The search microservice has one responsibility and only one : Searching Meetic users Some Meetic features : • Advanced Search • Shuffle (Tinder like) • Online profiles • Similar Profiles • Etc..
  • 13. The search microservice In order to do so, the search microservice should : • Be responsible of the way data is stored • Be aware of any data updates when the updates are in its scope • Return a list of profile’s ID when calling it
  • 14. The search microservice Event bus Consumer Search Exposition Layer
  • 16. About code structure in a microservice @ Meetic Don’t blame your messy code, blame the design pattern. (or the architect, or the tech lead, or the product owner)
  • 17. The hexagonal workflow Request (GET) Handler DAO Domain Object Domain Repository Populate Call Implements Infrastructure Application Domain
  • 18. Design pattern hexagonal Domain management Infrastructure implementation (repositories) Request management
  • 19. Design pattern hexagonal Define the “profile” domain object Implement the repository using Guzzle Handle the “search” request Define how profile should be get Implement the repository using Doctrine
  • 20. Ygritte …already has an account on Meetic
  • 21. Ygritte updates her Meetic Profile Event bus Consumer Picture Exposition Layer PUT { ”id”: 6789, “picture”: “me.jpg” } PUT { ”id”: 6789, “picture”: “me.jpg” } UPSERT { ”id”: 6789, “has_photo”: true }
  • 22. John …have just discovered Meetic. He wants to sign up.
  • 23. John signs up on Meetic (What should be done) Event bus Consumer Profile Exposition Layer POST { ”id”: 1234, “birthday”: “1989-01-12, ”picture”: “me.jpg” } POST { ”id”: 1234, “birthday”: “1989-01-12 } POST { ”id”: 6789, “birthday”: “1989-01-12, “has_photo”: true, “paymentStatus”: “free”, …. } GET /1234/pictures GET /payment-status/1234 GET … Picture POST { ”id”: 1234, “picture”: “me.jpg” }
  • 24. Theory vs reality Calling microservices + In case of change on any databases, this workflow stay unchanged + Avoid duplicated business logic - Don’t scale very well because of the number of http calls needed - Takes a lot of time to implement
  • 25. John signs up on Meetic (What is really done) Event bus Consumer Profile Exposition Layer POST { ”id”: 1234, “birthday”: “1989-01-12 } POST /reload/6789 Search SELECT * FROM PROFILE LEFT JOIN PAYMENT WHERE ID = 1234POST { ”id”: 1234, “birthday”: “1989-01-12, “eye”: “brown”, “paymentStatus”: “free”, …. } Picture POST { ”id”: 1234, “birthday”: “1989-01-12, ”picture”: “me.jpg” } POST { ”id”: 1234, “picture”: “me.jpg” }
  • 26. Theory vs reality Querying the database + The search microservice stays responsible of his data + Allows batch processing - Works only because databases are not yet split - Change on the database have to be replicated in the search microservice
  • 27. Managing big (SQL) queries with Symfony … using the compiler pass
  • 28. What does the reload query looks like? SELECT ID, BIRTHDAY, …, (SELECT * FROM …), FROM MEETIC.MEMBER INNER JOIN … LEFT JOIN… INNER JOIN… LEFT JOIN… LEFT JOIN… INNER JOIN… WHERE ( SELECT T FROM MEETIC.T WHERE … ) AND … OR…
  • 29. Keeping the reload query maintainable Since we chose to get data directly from the database when creating a new document in the index, the SQL query is huge and complex. • We need it to be easily shared, review and updated by DBAs • We need to keep it isolated so changes in the DB schema can be reported in a single file • We want to be able to just copy-paste it and check if it works.
  • 30. Managing big (SQL) queries with Symfony #1 Step : The application handle the request by calling the domain interface
  • 31. Managing big (SQL) queries with Symfony #2 Step : The domain describe how objects should be manipulated
  • 32. Managing big (SQL) queries with Symfony #3 Step : The infrastructure actually manipulate data.
  • 33. Injecting resources at compile time Service declaration :
  • 34. Injecting resources at compile time We use the Symfony CompilerPass to inject a file content as a string in the DAO.
  • 36. Ygritte is using the search engine
  • 37. Ygritte uses the search engine Exposition Layer Search POST { “query”: { “term”: { ”eyes”: “brown” } } } GET /search?eye=brown&hair=brown GET /search?eye=brown&hair=brown { ”memberId”: [ 1234, 456786, ] }
  • 38.
  • 39. Keeping the search logic clear Templating ElasticSearch queries with twig
  • 40. What does an ElasticSearch query look like? Most of the time the ElasticSearch query contains the larger part of the business logic. • Very long • Lot of strange json key • Lot of parameters And yet…
  • 41. Why not generating queries via php? • Managing big PHP array throw if…else is quite hard • It becomes harder to understand what actually does the query.
  • 42. Keeping the business logic clear with twig Templating the json query using twig let us know easily what actually does the query
  • 43. Keeping the business logic clear with twig Injecting parameters become easier.
  • 44. John is using the shuffle feature
  • 45. John uses the shuffle Exposition Layer Search POST { “query”: { ”must”: { “term”: { ”eyes”: “brown” } }, “must_not”: { ”terms”: { ”id”: [876,4567] } } } GET /search/1234/shuffle GET /search/1234/shuffle { ”memberId”: [ 5678, 09876, ] } GET /interaction/1234/black-list GET /referential/1234/search
  • 46.
  • 47. Building ElasticSearch query from multiple source …using the Guzzle promises
  • 48. Building query from multiple source Request (GET) Handler Enricher Domain Object Domain Repository Populate Call Implements Infrastructure Application Domain DAO DAO DAO
  • 49. Optimizing response time with Guzzle promises Http calls take time. Guzzle promises let us use parallelism in order to save precious milliseconds.
  • 50. Optimizing with Guzzle promises 1 2 3 4 5 6 1 2 3 4 5 6 Calls Time
  • 51. Conclusion Is that all theoretical or is it actually working in production?
  • 52. Search microservice in production • 19 millions hits per day • ~ 10 servers on 2 DC needed to be “Disaster Recovery Plan” friendly • Search route AVG response time : ~ 163 ms • Shuffle route AVG response time : ~ 336 ms