Everybody knows that it is hard to scale old highload monolithic projects that use pythonic templates for frontend. I am gonna tell how we transformed our product using trending and proper technologies like GraphQL, Apollo, Node.js with limited developer resources in a short period of time.
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
How to separate frontend from a highload python project with no problems - Pycon UA 2018
1. How to separate frontend
from a highload python
project with no problems
Oleksandr Tarasenko
EVO.company / prom.ua
2. Some prom.ua numbers
● RPS 2000-3000
● users over 2.5 million per day
● paid sites ~ 50 000
● total sites over 300 000
● products ~ 100 million
● pages ~ 300 million
2
3. What we had
● monolithic WSGI app (10 years)
● mako templates
● monolithic database
● monolithic Nginx
● poor REST API
● slow Delivery and Deployment
● new features were hard to develop
3
4. 4
1. Resolve url
2. Collect base context
3. Call render_mako
4. Collect template context
5. Return html
5. Our goals
● SEO
● Independent frontend
● Good user experience
● Documentation
● Data validation
● Microservices way
● Independent CI/CD
5
6. Tools and expertise
● ReactJS / Redux
● GraphQL server (hiku)
● Container system (vagga/lithos)
● Metrics (grafana)
● Logs (kibana)
6
10. Why we choose GraphQL
● good for readonly requests and data
● mutations to REST
● every site has unique user settings
● different templates
10
11. Some prom.ua sites code facts
● a lot of views and url endpoints
● almost no documentation
● poor versioning
● a lot of template context
● duplicating queries
11
12. We built two-level graph
● low-level graph for database mapping
(data loading)
● high-level graph for business logic
● auto documentation with graphiql tool
● data validation
12
19. Some facts of the new graph
● number of fields: ~ 500
● number of links: ~ 125
● number of nodes: ~ 75
● single entry point /graphql
● refactoring and new vision for code
● better monitoring
● easy to test API with graphiql
19
Hiku
21. Stateless ReactJS
● React Apollo
● React Router
● React Helmet
● No Redux/Flux/State management lib
21
22. Apollo client benefits
● great GraphQL implementation
● no sugar in React components
● query batching
● state cache
● community
● combine | join graphs (Apollo server)
22
24. 24
const articleViewQuery = gql`
query getArticleViewData($id: String) {
article(id: $id){
id
title
text
}
}`;
export const ArticleWithData =
graphql(articleViewQuery, {
options: ({ id }) => {
return { variables: { id } };
},
})(Article);
25. Other javascript implementations
● Relay modern / Relay classic
● Apollo client / Apollo server / Apollo engine
● Lokka
● Prisma
● GraphQL.js
● express-graphql
25