Decathlon Sport Meeting
Alonso Torres, DEVELOPER
Sports, a new Grails discipline
Antonio de la Torre, DEVELOPER
Kaleidos
Slide 2
Slide 2 text
Introduction
Slide 3
Slide 3 text
What’s Decathlon Sport Meeting?
Intro
Slide 4
Slide 4 text
Intro
Why want Decathlon to develop a Social Network?
● Decathlon’s mission is to make sports widely available
● Sport Meeting was created to take this one step further
Slide 5
Slide 5 text
Intro
Who developed it?
Kaleidos
Slide 6
Slide 6 text
What did it contributed to the community?
● 3 Pull Request to Grails
GRAILS-11647, GRAILS-11323, GRAILS-10763
● 6 open sourced plugins
Intro
Slide 7
Slide 7 text
Intro
How is DSM?
100k registered users
1000 active sport proposals
35 sports
Slide 8
Slide 8 text
Development Decisions
«The risk of a wrong decision is preferable
to the terror of indecision.»
Maimónides (12th c.)
Slide 9
Slide 9 text
Development decisions
Divided in
three applications
● WEB, JOBS, API
and a plugin with business
logic and common code
● CORE
JOBS
WEB API
CORE
Slide 10
Slide 10 text
Development decisions
Command Objects
● Responsibility
● Validate objects
○ accessing model to validate data
Slide 11
Slide 11 text
Development decisions
Command Objects
Check if is a type
and a valid domain object
Slide 12
Slide 12 text
Development decisions
Tests
●
Start with Integration tests << due to odd behaviour
●
and moving to Unit tests << less dependency
Slide 13
Slide 13 text
Development decisions
Asynchronous processes and background jobs
● Asynchronous processes (platform-core)
○ Immediate email sending
○ Push notifications to mobile devices
Slide 14
Slide 14 text
Development decisions
Asynchronous processes and background jobs
● Background jobs (quartz)
○ Quartz scheduler library
○ Tasks that are processed overnight
■ Proposals clean up
■ Mailing with interesting stuff (users, proposals)
Slide 15
Slide 15 text
API Decisions
Slide 16
Slide 16 text
API decisions
Trait with helpers to create responses: 4XX
Slide 17
Slide 17 text
API decisions
Command Objects accepts input JSON < Magic happens
Slide 18
Slide 18 text
API decisions
Command Objects accepts input JSON < Magic happens
API decisions
Data Oriented Design (RESTful)
over
Screen Oriented Design
Slide 21
Slide 21 text
Infrastructure decisions
Slide 22
Slide 22 text
Infrastructure decisions
PostgreSQL as our main database
● Open-Source and very mature
● Highly scalability
● Widely used
Slide 23
Slide 23 text
Infrastructure decisions
MongoDB as a secondary storage for denormalized data
● Optimize read and searches by storing documents
● Filter, sorting, querying
● Highly availability
Slide 24
Slide 24 text
Infrastructure decisions
MongoDB to store statistics and usage data
● Fire and forget model
● Map-reduce to extract the information
Slide 25
Slide 25 text
Infrastructure decisions
MongoDB for geolocalized data
● Great support of geolocalization
● Aggregation pipeline
Slide 26
Slide 26 text
Infrastructure decisions
Terracotta as a Hibernate second-level cache
and HTTP sessions
● Dual licensing (community and commercial)
● Problems scaling (on the community product)
● Decided to change to Redis
Slide 27
Slide 27 text
Infrastructure decisions
Releases upload to a Nexus repository
● Upload all the software revisions
● “release plugin” can manage this
● Could be easily automated for a continuous
delivery
Slide 28
Slide 28 text
Awesome Tools
«If I have seen further it is only by standing
on the shoulders of giants.»
Isaac Newton
Slide 29
Slide 29 text
Awesome tools
Java Melody Plugin
● Allows monitoring of requests and JVM state
● Saved us in several occasions
Slide 30
Slide 30 text
No content
Slide 31
Slide 31 text
Awesome tools
Build Test Data Plugin
● Creates complex objects from your constraints
Slide 32
Slide 32 text
Awesome tools
Build Test Data Plugin
● Creates complex objects from your constraints
Slide 33
Slide 33 text
Awesome tools
Build Test Data Plugin
● Creates complex objects from your constraints
Check constraints and
relationships and creates
the necessary objects
Slide 34
Slide 34 text
PostgresSQL Extensions plugin
Awesome tools
● Disclaimer: created by @ilopmar & @alotor inside
Kaleidos
● Provides native access to PSQL native types:
HSTORE, Arrays, JSON...
Slide 35
Slide 35 text
PostgresSQL Extensions plugin
Awesome tools
Slide 36
Slide 36 text
Awesome tools
Platform Core plugin
● Asynchronous task is a bliss
● Maintained by the Grails-core team
Slide 37
Slide 37 text
Awesome tools
Platform Core plugin
Slide 38
Slide 38 text
Know your tools
Slide 39
Slide 39 text
Awesome tools
GPars
● Easy parallelization inside the Groovy core
● Provides DSL’s and an easy API to parallelize
expensive tasks
● Sometimes difficult to work with GORM
Slide 40
Slide 40 text
Awesome tools
GPars
Slide 41
Slide 41 text
Awesome tools
GPars
Five threads at the same
time
Slide 42
Slide 42 text
Awesome tools
GPars
we need a transaction within
the new thread
Slide 43
Slide 43 text
Awesome tools
Groovy Metaprogramming
● Sometimes the magic is fun :)
● We developed a system with metaprogramming to
easily create new types of notification
Slide 44
Slide 44 text
Awesome tools
Slide 45
Slide 45 text
Awesome tools
Grails & Spring
● Problem: we wanted different implementations in
development and “real” environments
● Examples: notifications, file storage...
Slide 46
Slide 46 text
Awesome tools
Slide 47
Slide 47 text
Awesome tools
Inject a generic “fileService”
Slide 48
Slide 48 text
Awesome tools
Alias the necessary bean
per environment
Difficult Challenges
Tests pollution
● With 1500+ tests if you’re polluting one of your
tests is a big issue
● If this happens to you check:
by @tednaleid
http://bit.ly/1FlJs75
Slide 54
Slide 54 text
Difficult Challenges
API Documentation
● There is no easy way to keep an up-to-date API
documentation with Grails REST support
● Our solution: the documentation as GSP’s allow us to
reuse certain common part’s (like messages structure)
Slide 55
Slide 55 text
Difficult Challenges
MongoDB Plugin
● Mongodb’s GORM plugin had unexpected
behaviour
● We finally decided to use the low-level API when
accessing MongoDB
Slide 56
Slide 56 text
Going Forward
Slide 57
Slide 57 text
Going forward...
● Currently the application is only available for
spanish users
● Decathlon is present in 27 countries
Travel abroad!
Slide 58
Slide 58 text
Going forward...
● Decathlon Sport Meeting will be opening their API
● We hope to create an application ecosystem
around the social network
Opening the API
Slide 59
Slide 59 text
Going forward...
● First application using DSM API
● Was done during the ΠWEEK
Sport Spot