Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Stream Processing in LINE SPOT

Stream Processing in LINE SPOT

2019/07/31 LINE Developer Meetup 開發者小聚系列活動 #9
https://linegroup.kktix.cc/events/20190731

LINE Developers Taiwan

July 31, 2019
Tweet

More Decks by LINE Developers Taiwan

Other Decks in Programming

Transcript

  1. 8IBUT-*/&4105 10* 4FSWJD FT 4PDJBM $POUF OU 'PPE EFMJWFSZ 3FTFSWBUJPO

    5BYJ %FTJHOBUFE ESJWFS "SUJDMFT 3BOLJOHT &WFOUT 1SPNPUJPO T 6($ 'PMMPX
  2. • %JGGFSFOULJOEPGEBUBGSPNEJGGFSFOUQMBDFT • -*/&JOUFSOBM • 1BSUOFST • 4UPSF0XOFST • /PSNBM6TFST

    • %JGGFSFOULJOEPGRVFSJFTGJMUFST • ,FZXPSE GVMMUFYUTFBSDI • #ZMPDBUJPO • #ZSBUJOH 8IBUXFOFFEUPQSPDFTT
  3. Web App API Server(s) API Server(s) API Server(s) API Server(s)

    API Server(s) Reverse proxy/API Gateway DB Let’s start from an old school way DB write read replication
  4. • 8IPUIJTVTFSGPMMPXT 'PMMPXUBCMF • 8IBUUIFZQPTUFE "SUJDMFUBCMF • 6TFSOBNF QSPGJMFJNBHF 6TFSUBCMF

    • 8IPMJLFTMJLFDPVOU -JLFUBCMF • 8IPWJFXFEWJFXDPVOU 7JFXUBCMF • 8IPDPNNFOUFEDPNNFOUDPVOU $PNNFOU UBCMF 8IBUXFOFFEUPDPNQPTFUIFQBHF
  5. What your queries would like? Which DBMS you would pick?

    How many concurrent users to serve? How to cache the data? How you join data? What if user follows other 1000 users?
  6. Web App Reverse proxy/API Gateway DB How about in Microservice

    world (1st try) Timeline service User service Comment/Like service Article service DB DB User & Follower Article Comment/Like Separation of Concerns But… Problem still unsolved
  7. What if … We could use one single query to

    get all data we need We join and prepare data before we need it But how?
  8. Web App Reverse proxy/API Gateway DB Timeline service User service

    Comment/Like service Article service DB DB User & Follower Article Comment /Like Messaging System publish Event consumer Materialized view consume
  9. POI service Coupon service Product service POI DB Kafka Connect

    Coupon DB Product DB Kafka Connect Kafka Connect Store Locator Service Kafka Stream View DB Kafka Connect Process store view data store view data Elastic Search MySQL MySQL MySQL
  10. val stores: KStream[Long, Store] = storeDetails .mapValues(withOpeningHours _) .mapValues(withPhone _)

    .leftJoin(couponsByStore) { case (details, StoreCoupons(items)) => Store(details, images = List.empty, coupons = items) case (details, null) => Store(details, images = List.empty, coupons = List.empty) } .leftJoin(imagesByStore) { case (store, StoreImages(items)) => store.copy(images = items.sortBy(_.ordinal)) case (store, null) => store } .toStream .mapValues( store => if (store == null || store.details.deleted) { null } else { store } ) &YBNQMF KTable