Recommended system | ① Movies Overview

 

Data Lifecycle

   

 

Project System Architecture

             

   Users Visualization: primarily responsible for implementing and display user interaction and traffic data, the main use AngularJS2 be achieved, deployed on Apache service.

   Integrated services: the main achievement of overall business logic level JavaEE, constructed by Spring, docking business needs. Deployed on Tomcat.

[Section] Data storage

  Business Database: project uses the document database MongDB widely used as the primary database, the storage platform is mainly responsible for the business logic of the data.

  Search Server: Project love with ElasticSearch as fuzzy search server to achieve content-based recommendation service through the use of ES powerful query capabilities to match.

  Cache Database: project uses Redis as a cache database is mainly used to support real-time recommendations system part for high-speed data acquisition needs.

Recommended section [offline]

  Offline Statistical Service: Batch statistical services using Spark Core + Spark SQL carried out to achieve, achieve statistical tasks on the Indicator data.

  Offline referral service: offline recommendation service using Spark Core + Spark MLlib be achieved using ALS algorithm implementation.

  Work scheduling service: For offline recommendation needs to be a certain part of time-frequency algorithm scheduling, adopt Azkaban scheduling tasks.

[Section] real-time recommendations

  Log collection service: the business user platform by using the Flume-ng for a movie score behavior acquisition, real Kafka sent to the cluster.

  Service message buffer: Item Kafka employed as the streaming data caching components, receiving the data acquisition request from the Flume. And push data in real-time recommendation system part of the project.

  实时推荐服务:项目采用Spark Streaming作为实时推荐系统,通过接收Kafka中缓存的数据,通过设计的推荐算法实现对实时推荐的数据处理,并将结构合并更新到MongoDB数据库。

项目数据流程

             

 

                 

 

 

【系统初始化部分】

  1. 通过Spark SQL将系统初始化数据加载到MongoDB和ElasticSearch中。

【离线推荐部分】

  1. 通过Azkaban实现对于离线统计服务以离线推荐服务的调度,通过设定的运行时间完成对任务的触发执行。
  2. 离线统计服务从MongoDB中加载数据,将【电影平均评分统计】、【电影评分个数统计】、【最近电影评分个数统计】三个统计算法进行运行实现,并将计算结果回写到MongoDB中;离线推荐服务从MongoDB中加载数据,通过ALS算法分别将【用户推荐结果矩阵】、【影片相似度矩阵】回写到MongoDB中。

【实时推荐部分】

  1. Flume从综合业务服务的运行日志中读取日志更新,并将更新的日志实时推送到Kafka中;Kafka在收到这些日志之后,通过kafkaStream程序对获取的日志信息进行过滤处理,获取用户评分数据流【UID|MID|SCORE|TIMESTAMP】,并发送到另外一个Kafka队列;Spark Streaming监听Kafka队列,实时获取Kafka过滤出来的用户评分数据流,融合存储在Redis中的用户最近评分队列数据,提交给实时推荐算法,完成对用户新的推荐结果计算;计算完成之后,将新的推荐结构和MongDB数据库中的推荐结果进行合并。

【业务系统部分】

  1. 推荐结果展示部分,从MongoDB、ElasticSearch中将离线推荐结果、实时推荐结果、内容推荐结果进行混合,综合给出相对应的数据。
  2. 电影信息查询服务通过对接MongoDB实现对电影信息的查询操作。
  3. 电影评分部分,获取用户通过UI给出的评分动作,后台服务进行数据库记录后,一方面将数据推动到Redis群中,另一方面,通过预设的日志框架输出到Tomcat中的日志中。
  4. 项目通过ElasticSearch实现对电影的模糊检索。
  5. 电影标签部分,项目提供用户对电影打标签服务。

 

加载数据

Movies数据集   电影数据表

数据格式:

mid,name,descri,timelong,issue,shoot,language,genres,actors,directors

                                    

Ratings数据集   用户评分表

数据格式:

userId,movieId,rating,timestamp

      

 

 

Tag数据集  电影标签表

数据格式:

userId,movieId,tag,timestamp

     

日志管理配置文件

log4j对日志的管理,需要通过配置文件来生效。在src/main/resources下新建配置文件log4j.properties,写入以下内容:

log4j.rootLogger=info, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}  %5p --- [%50t]  %-80c(line:%5L)  :  %m%n
View Code

数据初始化到MongoDB、ElasticSearch

 数据加载程序主体:

      为原始数据定义几个样例类,通过SparkContext的textFile方法从文件中读取数据,并转换成DataFrame,再利用Spark SQL提供的write方法进行数据的分布式插入。

DataLoader/src/main/scala下新建package;

将数据写入MongoDB   写入ElasticSearch

接下来,实现storeDataInMongo方法,将数据写入mongodb中:

同样主要通过Spark SQL提供的write方法进行数据的分布式插入,实现storeDataInES方法:

\MovieRecommendSystem\recommender\DataLoader\src\main\scala\com\xxx\DataLoader\DataLoader.scala

 

 

Guess you like

Origin www.cnblogs.com/shengyang17/p/11546299.html