Remember the development process of a social app-infrastructure selection (from a big brother)

Source: Internet
Author: User
Tags nginx reverse proxy rabbitmq

Remember the development process of a social app--Infrastructure selectionCatalogue [-]
    • Basic Product Form
    • Technology selection

The last two weeks are busy developing a social app, because before doing a bit of social things, it was pulled to do the API backend, a head of a complete set of things, there is no PM and all kinds of urging, the process is very relaxed happy full of fun, now the backend has been basically completed, Next week will go into the phase of the test, some things want to write a record, first from the technology selection start.

Basic Product Form

The basic function of the product is nothing more than the things that all social apps have, new, good friends (like Weibo, one-way follow), geographic location (current location, people near you), and more small details and features are now not readily disclosed:)

In fact, social this product gives me the feeling has been very strange, compared to the technology and those who pull the interaction of the product analysis, this thing is more fascinating is a psychological magic, such as said about the Cannon app, you may think of Momo, but Mo Mo's product level with many social apps is the same, is also a feed, Follow and geographical location, and our normal social, normal circle of friends with the most is rather than Mo Mo, but when the dead of night you want to kill lonely, may go to use Mo mo, although the function and technology similar, but some product details on the user's hint has caused a completely different results, with QQ, MSN, gtalk feel similar, although their main function is chatting, but their user groups and the use of the atmosphere is completely different. Combined with their own needs, to experience the psychology of the target users, to find ways to meet their own and user's psychological appeal, this is to do social types of products the greatest pleasure.

Technology selection

The beginning of the technology selection is simple and clear, as soon as possible to achieve ideas, reduce the complexity of the introduction, but to try to prepare for the future expansion of such an idea. Many Internet entrepreneurial soul chicken soup such as "hackers and painters", "rework" is probably so advocated, the first thing quickly made, and then based on the user's feedback to find the problem of rapid iteration. Here's a look at the technology stack I'm using:

1. Language:

Life is short, I use Python

2. Storage and data access tools:

There are a lot of choices for storage in this era, but I still choose the MySQL I am most familiar with because I don't have to say much. According to previous experience, such as the user table This will remain motionless, but some tables, such as the feed index I did sharding in the beginning of the processing (about the implementation of the feed and storage structure I will be introduced later). Another very important thing is the implementation of the data access layer, although some things, such as read and write separation support, but I do not want to support, at least to consider this situation will happen in the future, it is not too hard to rewrite the code everywhere, in addition to Sharding, To make it easy to access the usual tables, you'll end up with a bit of ORM functionality.

The first thing to do is to write this data access tool, the business is to delete and change the search, no this guy how to live!? With Python two hundred or three hundred lines of code to the Web.py data Access module to do the next package to make such a thing, https://github.com/chihongze/shard.py can eventually achieve read-write separation and support for sharding. Of course, in the process of use to find a lot of problems, some queries can not be very good to meet the needs Ah, and so on, perfect.

3. Caching

Because this project belongs to 80/20 kind of extracurricular hobbies, less resources, the beginning also do not want to big push, just to the surrounding small partners first play, programmer strange Uncle beat sister A laugh what, can have two or three machines is very good, so for the legendary distributed cache, think or forget, most things or directly read the library, But what do you do with a Redis? The main thing is three things: 1, save token 2, record user online status 3, anti-brush business "you entered too fast, please take a break to continue," and so on. But all of the data is taken to the storage layer, and then if you want to cache, you can add directly to the storage layer, without having to violate the upper business logic.

4. Static storage

Do social to the picture quality requirements are very high, most of them will be in the background specifically to take out the machine with Image magic and other services, but for the start-up social apps, make this stuff is very resource-intensive, consider the cost-effective, development costs, directly using the service of the cloud, The image storage and processing problems are taken care of in an instant.

5. Message Queuing

For social, a lot of things, for example, if you have tens of thousands of followers, and I'm going to push the naked photo you just sent to these 10,000 people, then you can't wait until all the pushes are over and return to you, and then I'll give you a quick return to the results of the successful delivery, and push this thing behind the scenes and let it play on its own. This requires a lot of scenarios, and then you need to use Message Queuing. Message Queuing products also have a lot to choose from, http://www.cnblogs.com/amityat/archive/2011/08/31/2160293.html This article makes a general introduction to the current popular message queue. Personal view of Message queue selection, one is stable, out of the wrong good recovery, two is easy to monitor, the queue blocked ah what I can easily monitor, three is concurrency, four is easy to use interface. These four points, rabbitmq obviously win. I chose the RABBITMQ. Some details about the use of RABBITMQ will be introduced when the feed is distributed.

7. API Server

API is all restful, with the web framework is web.py, the current debugging phase is only web.py directly to the client to do debugging, on-line ready to go after the reverse proxy nginx, in addition to recently also study this project:/http Www.oschina.net/p/gunicorn can choose Nginx + WSGI module + web.py mode, can also be Gunicorn + web.py, Nginx reverse proxy to Gunicorn.

For the usual API, Using web.py is easy to meet, but for our application, private chat is one of the most important functions, so the intention is to split the chat service, take Tornado to do, Tornado do long links more professional, unlike Web.py,tornado itself is an asynchronous web framework, like node . js that way.

The overall technology selection is these things, very simple, are very mature some of the technology, there is no new things, but the development is still pretty cool, especially the development of Python's efficiency is not said, such as the support sharding data access tools, originally used Java to do similar things, To the spring Jdbc template to do the package, seemingly wrote more than 10 classes of files, made a lot of days, now with Python two hundred or three hundred line asserting chest meaning a morning on the second off, the development efficiency is not a grade, ha haha.

Remember the development process of a social app-infrastructure selection (from a big brother)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.