App Back-end technology
The direction of the work has always been Web server, with little understanding of App server. Although not in touch with mobile app development, but the app back-end technology is still very exploratory desire, app and Web applications in the front end of the user habits, I believe the backend will have a lot of different places. This article records some of the Internet-collected app backend technology systems for your understanding.
Here are a few things that the app server typically needs to consider in terms of business design:
1. API Style
How to design a reasonable and elegant set of API interfaces, you can refer to the RESTful sub-grid:
- API uses the HTTP (s) protocol to communicate with the front-end;
- Each URI represents a resource (resource), which is represented by an HTTP method (such as Get, POST, put, and so on) for the type of operation of the resource. For example:
Get/zoos: List all Zoos Post/zoos: Create a new Zoo GET/ZOOS/ID: Get information about a designated Zoo PUT/ZOOS/ID: Update a reference Information about the zoo (provide all information about the zoo) delete/zoos/id: Delete a zoo get/zoos/id/animals: List all the animals in a given zoo delete/zoos/id/animals/ ID: Delete a designated animal from a designated zoo
- Filter results by parameters, such as
limit=10: Specify the number of records to return? OFFSET=10: Specifies the start position of the returned record. Sortby=name &order =ASC: Specifies which attribute the returned result is sorted by, and the sort order. Animal_type_id=1: Specify filter Criteria
- The data format returned by the server is as JSON-based as possible;
- API authentication key uses the OAuth 2.0 framework;
- Return error codes and error messages to facilitate error handling and exception protection at the front end;
2. Chat Service
Chat Server Select OpenFile, which is an XMPP protocol-based chat servers.
In addition to providing chat services, XMPP can also act as a messaging server.
3, SMS, mail, push service
First, a variety of message pushes must be handled in the queue, otherwise it will seriously affect the API response time.
Mobile SMS:
Usually to use some third-party SMS service platform provided by the interface, this nothing to say;
Email aspect:
To consider the resend of the message failed to send the problem, so no longer on the server to build SendMail service sent, select the mail service provider Mailgun. Mailgun also offers a free amount of 10,000 emails per account per month, ideal for start-up teams.
Message Push aspects:
1, APNs is the choice of iphone push. However, if you develop APNS services, you will encounter invalid tokens and need to be re-sent, so you need to maintain a queue and establish a re-development mechanism.
When the user uninstalls the app on the iphone, device token fails, so you should periodically visit Apple's feedback server and remove the invalid token.
2, Android, there is Google's C2DM platform, but the C2DM server in foreign countries, domestic use seems to be less available;
4. LBS
In LBS applications, a basic requirement is to find nearby users (or merchants) and there are two ways to do it:
1. Use MySQL's spatial database, specific practice reference: http://blog.sina.com.cn/s/blog_a48af8c001018q1p.html.
2. Use Geohash encoding.
With regard to Geohash coding, it transforms the latitude and longitude on the spherical surface into a value, which is simply to convert the two-dimensional coordinates into one-dimensional coordinates. It's very convenient to find nearby, and in SQL, like ' w23yr3% ' can query all nearby locations.
When the volume of data retrieval is particularly large, the problem of slow query can be solved by using coreseek+redis+mysql.
Ps:coreseek is a full-text search engine based on Sphinx.
5. Dynamic Notification
Often a small red circle is visible in the top right corner of many apps, and there is a number in the circle that indicates how many new messages arrive to awaken the user's desire to open.
On the app side, how do you know how many new notifications you have? There are two techniques to implement:
1. Polling:app Timing Query
2. Push: The server is pushed to the app in real time
In contrast, push is more efficient and avoids frequent queries to the server, increasing the pressure on the server and consuming more of its own traffic and power.
6. Incremental update of data
7. Security
The data communicated by the user and the back-end server should not be transmitted in clear text, especially sensitive information involving the user's account number and password.
For example, the user logon process can use the SSL protocol to exchange data.
I was in HKEx before. The Diffie-hellman algorithm used in the receiving project is a good key exchange algorithm:
Reference Documentation:
1, Zeng Jiansen, "app backend" http://blog.csdn.net/newjueqi/article/category/1743543
2, Nanyi, "RESTful API Design Guide" http://www.ruanyifeng.com/blog/2014/05/restful_api.html
3, "Find the vicinity of the xxx spherical distance and Geohash scheme discussion" http://www.wubiao.info/372
4. Introduction to the implementation principle of XMPP protocol http://www.cnblogs.com/hanyonglu/archive/2012/03/04/2378956.html
App Back-end technology