APP remember a social development process - Infrastructure Selection

In the last two weeks been busy developing a social App, because the little things done before the social aspects of the API is pulled to do the back-end, and the first time a person to take such a complete set of things, and all kinds of above nor PM urging, the process is still very pleasant and fun, and now has been basically completed the back-end, next week will enter the stage of the FBI tests, a written record some things to write about, start with the technology selection begins.

The basic product form

Basic function of the product is nothing more than those things, new, friends all social relations App will have (the same as microblogging, one-way follow), location (current location, the people near you) more small details and functions the point now is not easy to reveal :) in fact, this social product to my feeling has always been very strange, product analysis techniques and those who pull the interaction with respect, something even more fascinating is a psychological magic, such as App said above about guns, you might think of unfamiliar street, but the street street-level product with many social App is the same, but also feed, follow and geographic location, and our normal social, the normal circle of friends with most of the a micro-channel rather than unfamiliar street, but when you want to rid the dead of night lonely, might go with unfamiliar street, though similar features and technology, but some of the details of the product implies that the user has caused a completely different result, with QQ, feel between MSN, Gtalk similar, although their main function is to chat, but their user base and use a completely different atmosphere. Combined with their own needs, to experience the target user's psychological, and find ways to meet their own psychological demands of users, which is the largest type of product do the social fun of it.

Technology Selection

Technology selection beginning of faith is clear and simple idea as soon as possible, to reduce the complexity of the introduction, but to try to prepare for such an idea for future expansion. Many Internet entrepreneurs such as Chicken Soup "Hackers and Painters", "Rework" is probably also advocated so, first thing to do it quickly, then found the problem rapid iteration based on user feedback. Here's what I use technology stack: 1. Language: Life is short, I used Python 2. storage and data access tools: choose this store's facing really a lot, but I still choose their most familiar MySQL, the reasons do not have to Say. According to previous experience, such as user table that will remain intact, but some tables, such as feed index at the outset I made a deal with sharding (regarding the implementation and feed storage structure I will be described later). Another important thing is the data access layer is achieved, although some things, such as separate read and write support will not be used now, but I felt I should support, at least to consider this would happen in the future, when the time It will not bitter forced to rewrite the code everywhere, the other for sharding, usually to do with access to a table similarly light, and finally to an aura of ORM functionality. The first thing to do is to write the data access tools, business is CRUD Why not this guy how to live! ? Two or three hundred lines of code in python for web.py data access module do the next package to come up with such a thing be, https://github.com/chihongze/shard.py  And final separation can read and write the support sharding. Of course, in the process of discovery with the many problems, some queries can not meet the demand ah, etc., perfected. 3. Cache because the project belongs to the kind of after-school hobby 80/20, fewer resources, most do not want to start big push, just to have around the small partners to play, what programmers strange uncle sister smile stroke, to have two three machines is very good, so for the legendary distributed cache, think about or forget, or directly read most of the stuff library, but still take up a Redis, Zuosha use? Mainly three things: 1, save the token 2, record 3 users online, anti-brush business "too fast you type, please continue to take a break," and the like. But to get all the data storage layer or go, if you want to add to the time the cache can be directly applied to the storage layer, without having to infringe the top business logic. 4. static storage do social picture quality requirements are high, most of them will come up with a special machine in the background image magic ride cut plan and other services, but the start-up of the social app, to engage in this kind of thing very resource-intensive, consider the cost, development cost, the direct use another shot of cloud services, and instantly get problems image storage and processing. The message queue for social networking, many things, such as you have tens of thousands of fans attention, I want you just made a nude pushed to the million people, then certainly can not wait for all of you will push back to results that impatience will wait, I will return to you immediately send the results of success, to push this thing into the background and let it play. Such scenes have a lot of demand, then you need to use the message queue. Message Queue products also have a lot of choice, http://www.cnblogs.com/amityat/archive/2011/08/31/2160293.html  This article of the now popular message queue done under general introduction. Personal opinions about the message queue selected, one is stable, gone wrong good recovery, the second is easy to monitor, queue blocked ah, what can I easily monitored, the third is concurrency, fourth is the interface to be easy to use. These four points, RabbitMQ clear winner. On the selection of the RabbitMQ. Some details about the use of RabbitMQ, will do related presentations when feed distribution. 7. API Server API is a RESTful whole, web framework using a web.py, the current commissioning phase but also to the client web.py direct foreign students do debugging on the line ready to go Nginx reverse proxy, the other more recently this research project: http://www.oschina.net/p/gunicorn  can choose Nginx + wsgi module + web.py mode can also be gunicorn + web.py, nginx and then reverse proxy to gunicorn. For a typical API, use web.py easy to meet, but for our applications, private chat is one of the most important functions, and therefore intends to split out the chat service, to do it alone take tornado, tornado did more long link Some professional, unlike web.py, tornado itself is an asynchronous web frameworks like Node.js that. The overall technology selection is that these things right, very simple, some are very mature technology, but also nothing new use, but the development is still quite cool, especially it is not to say that Python development efficiency, such as the supports sharding data access tools originally used Java has done similar things to do on Spring Jdbc Template package, seemingly written more than a dozen types of documents, engage in many days, and now with two or three hundred lines straight from Python chest intention morning on the second out, the efficiency of development entirely a grade, ha ha ha.

Reproduced in: https: //my.oschina.net/wzlee/blog/262206

Guess you like

Origin blog.csdn.net/weixin_34166847/article/details/91716714