A social network with unidirectional follow relationships, implemented with loosely-coupled microservices, communicating with each other via Thrift RPCs.
Supported actions:
- Create text post (optional media: image, video, shortened URL, user tag)
- Read post
- Read entire user timeline
- Receive recommendations on which users to follow
- Search database for user or post
- Register/Login using user credentials
- Follow/Unfollow user
- Docker
- Docker-compose
- Python 3.5+ (with asyncio and aiohttp)
- libssl-dev (apt-get install libssl-dev)
- libz-dev (apt-get install libz-dev)
- luarocks (apt-get install luarocks)
- luasocket (luarocks install luasocket)
- Install Docker and Docker Compose.
- Make sure the following ports are available: port
8080
for Nginx frontend,8081
for media frontend and16686
for Jaeger.
Start docker containers by running docker-compose up -d
. All images will be
pulled from Docker Hub.
Before starting the containers, make sure you are on the master node of the docker swarm nodes.
docker stack deploy --compose-file=docker-compose-swarm.yml <service-name>
Register users and construct social graph by running
python3 scripts/init_social_graph.py --graph=<socfb-Reed98, ego-twitter, or soc-twitter-follows-mun>
. It will initialize a social graph from a small social network Reed98 Facebook Networks, a medium social network Ego Twitter, or a large social network TWITTER-FOLLOWS-MUN.
cd ../wrk2
make
back to socialNetwork
cd ../socialNetwork
../wrk2/wrk -D exp -t <num-threads> -c <num-conns> -d <duration> -L -s ./wrk2/scripts/social-network/compose-post.lua http://localhost:8080/wrk2-api/post/compose -R <reqs-per-sec>
../wrk2/wrk -D exp -t <num-threads> -c <num-conns> -d <duration> -L -s ./wrk2/scripts/social-network/read-home-timeline.lua http://localhost:8080/wrk2-api/home-timeline/read -R <reqs-per-sec>
../wrk2/wrk -D exp -t <num-threads> -c <num-conns> -d <duration> -L -s ./wrk2/scripts/social-network/read-user-timeline.lua http://localhost:8080/wrk2-api/user-timeline/read -R <reqs-per-sec>
View Jaeger traces by accessing http://localhost:16686
Example of a Jaeger trace for a compose post request:
After starting all containers using docker-compose up -d
, visit http://localhost:8080
to use the front end.
First you could see the login and signup page:
In order to load default users into database, visit http://localhost:8080/main.html
once. Then click compose to post new contents.
After composing a few posts, you could see your own posts in user timeline page. Click follow button on the right side to follow defualt users:
To see your own posts in home timeline page, click the username and profile button:
Posts could be mixed with text, user mention and image.
Click the contact button to follow/unfollow other users; follower/followee list would be shown below in form of user-id:
If you are using docker-compose
, start docker containers by running docker-compose -f docker-compose-tls.yml up -d
to enable TLS.
Since the depends_on
option is ignored when deploying a stack in swarm mode with a version 3 Compose file, you
must turn on TLS manually by modifing config/mongod.conf
, config/redis.conf
, config/service-config.json
and
nginx-web-server/conf/nginx.conf
to enable TLS with docker swarm
.
start docker containers by running docker-compose -f docker-compose-sharding.yml up -d
to enable cache and DB sharding. Currently only Redis sharding is available.
This application is still actively being developed, so keep an eye on the repo to stay up-to-date with recent changes.
- Upgraded recommender
- Upgraded search engine
- MongoDB and Memcached sharding
You are welcome to submit a pull request if you find a bug or have extended the application in an interesting way. For any questions please contact us at: [email protected]