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

Personalized Content Recommender System on Spring

Personalized Content Recommender System on Spring

LINE Developers

March 25, 2019
Tweet

More Decks by LINE Developers

Other Decks in Technology

Transcript

  1. About me @hackmylife • ຊ໊ ౉ᬒ ௚थ ௨শ നถ •

    ։ൃ̐ηϯλʔ > AP3 team • Senior server side engineer • livedoorχϡʔε, LINEΪϑτ, LINE BLOG • LINE Ads Platform • Smart Channel • Spring fest 2018 fall
  2. UX

  3. • Redis • MySQL • Kafka • Spring boot 2

    • lettuce5 • MyBatis + kotlin • Caffeine • fastutil, guava Spec
  4. Application 86 pm servers 40 vm servers MySQL 3 vm

    servers Redis 100+ vm instance (Redis cluster) Kafka In-house common (Kafka cluster) Log storage In-house common (Hadoop) Servers
  5. CRS Engine Flow Event Tracker Joiner Learning worker Importer LINE

    App Contents Contents Imp/Click Log Log Parameter
  6. CRS Engine 1. Importer Event Tracker Joiner Learning worker Importer

    LINE App Contents Contents Imp/Click Log Log Parameter
  7. • Mapping provider͔Βɺrecommend item ͷID͚ͩ΋Β͏ • item͕ͲΜͳσʔλΛ͍࣋ͬͯΔ͔໰͍ ߹ΘͤΔ • Redisʹmapping

    ͱ contentsΛstore͢Δ Importer user_id1 \t item_id1, item_id2, item_id3 user_id2 \t item_id3, item_id4 user_id3 \t item_id1, item_id2, item_id6 { "items": [ { "originalId": "12345678", "title": “ࣗ෼ͷೳྗΛݟۃΊͯ", "description": "ແཧͳεέδϡʔϧͰମௐΛ่ͯ͠͠·͏ΑΓɺ ૉ௚ʹपΓʹཔΓ·͠ΐ͏ɻࠓ͸ࣗ෼ʹݫͯ͘͠͠͠·͍͕ͪɻ ࣗ෼ͷೳྗΛ௒͑ΔͱࢥͬͨΒঢ়گΛ࿩ͯ͠ڠྗͯ͠΋Βͬͯ͘ ͍ͩ͞ɻ", "linkURL": “line://ch/1391620050/z/fortune/detail/2/20181011", "iconURL": “http://example.com/path/to/image1.png" }, ……. ] }
  8. • Recommendation dataͭ͘Δͷ͸ ML engineer • Master data ؅ཧͯ͠Δͷ͸ Service

    side engineer • ୲౰෦ॺ͕ҧ͏ʢ৔߹ʹΑͬͯ͸ࠃ΋ҧ͏ʣ • RecommendΛ࡞ͬͨ࣌ͱ͕࣌ࠩ͋Δ Կނ2ճʹ෼͚ͯσʔλΛऔΔ͔
  9. CRS Engine 2. CRS Engine Event Tracker Joiner Learning worker

    Importer LINE App Contents Contents Imp/Click Log Log Parameter
  10. • UserຖʹRecommend contentsऔಘ • Frequency cap / mute / opt-outͳͲͰfiltering

    • Recommend itemΛRanking্͔ͯ͠Βn݅ฦ͢ • Contextual bandit algorithmsΛ࠾༻ CRS Engine
  11. Mono/Fluxͷྫ targetingRedis.mget(keys) // ͜͜͸Flux͕ؼͬͯ͘Δ .filter(KeyValue::hasValue) .map(keyValue -> Maps.immutableEntry(extractTargetingType(keyValue.getKey()), keyValue.getValue())) .collectMap(Map.Entry::getKey,

    Map.Entry::getValue); // ໭Γ஋͸ɹMono<Map<String, List<String>>> Key: user_id:news Val: ["65819383620a","48d2872c86c6","293d0a33f938","c43cd18c98f4"] Key: user_id:weather Val: [“1"] -> ͜ΕΛnews, weatherΛkeyͱͨ͠Mapͱ͔ʹͯ͠ฦ͍ͨ͠ ࣮ࡍʹॲཧ͞ΕΔͷ͸subscribeͨ࣌͠
  12. User side • Gender • Age • Interests Contents side

    2-side features • Time • Id • Score
  13. CRS Engine 3. Event Tracker Event Tracker Joiner Learning worker

    Importer LINE App Contents Contents Imp/Click Log Log Parameter
  14. @Configuration @RequiredArgsConstructor @EnableConfigurationProperties({ KafkaStreamsProperties.class, KafkaTopicProperties.class }) public class KafkaStreamsConfiguration {

    @Bean public KafkaStreams muteEventStream( KafkaStreamsProperties streamsProperties, KafkaTopicProperties topicProperties ) { final StreamsBuilder builder = new StreamsBuilder(); builder.stream(topicProperties.getMuteEvent(), Consumed.with(new StringSerde(), new StringSerde())) .foreach((key, value) -> { try { // Կ͔ॲཧ } catch (Exception e) { // ྫ֎ॲཧ } }); KafkaStreams streams = new KafkaStreams(builder.build(), streamsProperties.getMuteEventStream()); streams.setUncaughtExceptionHandler((thread, e) -> { log.error("Uncaught exception in StreamThread.", e); }); streams.start(); return streams; } }
  15. kafka: servers: server1, server2, server3 metrics-reporter: com.example.awesome.kafka.metrics.PrometheusMetricsReporter topic: mute-event: awesome-mute-event-v1

    stream: mute-event-stream: "bootstrap.servers": ${kafka.servers} "application.id": crs-mute-event "state.dir": /path/to/kafka-streams "num.stream.threads": 6 "replication.factor": 3 "metric.reporters": ${kafka.metrics-reporter} consumer: "max.poll.records": 100 "auto.offset.reset": earliest @ConfigurationProperties(prefix = "kafka.stream") public class KafkaStreamsProperties { @NotNull @Valid private Properties muteEventStream; }
  16. CRS Engine 4. Joiner Event Tracker Joiner Learning worker Importer

    LINE App Contents Contents Imp/Click Log Log Parameter
  17. CRS Engine 5. Learning worker Event Tracker Joiner Learning worker

    Importer LINE App Contents Contents Imp/Click Log Log Parameter
  18. subtitle Developers • Server side engineer 5 ਓ • ML

    team΍֤Service developerͱίϥϘϨʔγϣϯ • Globalͷϝϯόʔͱͷ΍ΓऔΓ΋සൟʹ͋Δ • ·ͩ·ͩ໘ന͍Spec͋ΔͷͰ΍͍͖͍ͬͯͨ