Renren mobile development architecture

Source: Internet
Author: User
Tags keep alive

 

Speaking of the Development of Mobile Phone operating platforms, we should first talk about the development of mobile terminals, because the development of platforms is inseparable from mobile terminals. The development and future trends of mobile terminals in the last decade can be divided into the following four phases:

 

Phase 1:Function terminal. It can meet users' basic communication needs, such as sending text messages and making phone calls, and attaching some snake and box-pushing games.

Stage 2:Smart terminals. Third-party applications can be expanded to provide Internet browsing and other basic functions, represented by the Nokia s60 mobile phone.

Stage 3:Internet and platform-based terminals. Mobile phones are more closely connected with the Internet, browsers and streaming media are more powerful, and Internet applications and mobile phone system features are more closely integrated. Mobile phones have become a platform, users can download third-party applications to DIY this terminal, such as preference music, and can download music applications. IPhone, Android, and Windows Phone 7.

Stage 4 (future trends ):Iot-based smart terminals. This phase is characterized by the closer integration of real life and networks through sensor devices.

At present, we are in the third stage. for users, different incomes, interests and hobbies, different requirements and preferences, as well as the characteristics of mobile phone private attributes and portability have produced different user experiences; for various manufacturers, different mobile phone operating systems are created due to different target market positioning, different commercial interests, and different technical backgrounds. In the end, mobile phone operating platforms were diversified.

Currently, mainstream mobile phone operating platforms include Symbian, Android, iPhone OS, MTK, Windows Mobile, and WP7. The following describes the situation of these six platforms.

Symbian:Although the old king has suffered a strong attack from Android and iPhone, it has been divided into some markets, but the price is low, the ease of use is strong, there are many applications, plus Nokia's brand, channel and other advantages, in the short term, the dominant position of smart machines is hard to shake. In the medium term, the market center moves down to the middle-end and low-end smart machines. In the long term, it may be replaced by WP7. If it does not change its life, it is likely to be revolutionized by others.

Android:According to foreign media reports, Android surpassed Symbian in the fourth quarter of last year to become the world's largest smartphone platform, ending its 10-year dominance in the field of smart phones. Later, Android draws on the iPhone operating experience. However, because Android is fully open-source, it is easy for mobile phone manufacturers and operators to customize their own mobile phones with their own characteristics and services, coupled with the powerful Internet functions of Android, It is favored by both. Completely open source is a double-edged sword. Because each vendor has defined their own products, such non-standard and non-uniform will bring a threshold for third-party software adaptation, this may result in fewer Android applications on a single mobile terminal of a certain type. Therefore, Android may become a mobile phone.

IPhone OS:Mythical creators, we can see from the popularity of the iPhone 4 miracle. The superb UI design, good interactive operations, and massive applications firmly occupy the high-end market. In the short term, the outstanding advantages of the iPhone 4 will put it on fire for a while. However, because it is a self-owned system, the market share depends on the acceptance of Apple's mobile terminal users. For a long time, it mainly depends on the development of Apple's mobile phone and the changes of competitors.

Windows Mobile:Is it okay? Both iPhone and Android are defeated in terms of UI visual effects, usability, and third-party applications. It's time to retire.

MTK:Http://service.ap-southeast-3.maxcompute.aliyun-inc.com/api. It must be completed by intermediate vendors. In comparison, third-party programs are fewer and easier to use. The price and function-based cost-effectiveness advantages of shanzhai machine occupy the low-end market.

WP7:The savior, as a life-saving tool for Microsoft and Nokia, is worth looking forward to. I have experienced WP7 and used a scroll-like uidesign style to make the UI experience unique. The close integration of the system and Internet applications, coupled with the strong support of Nokia and Microsoft. This operating system is worth looking forward to, and is expected to form a three-pronged situation in the smart machine field: WP7, Android, and iPhone.

The above six platforms correspond to different experiences and functions. For product designers and developers, they generally refer to the uidesign specifications of mobile terminals. The mobile terminal system defines some common controls and response methods. Keeping the product consistent with the terminal system not only reduces development costs, but also makes it easy for users to learn and use. In the face of many platforms, especially various platforms with different features, different operation methods and different screen sizes, and each mainstream platform has a large user base with many different UI specifications, this is undoubtedly disastrous for products across the platform.

This article discusses differences between different terminal platforms and unified architecture in Renren mobile development, as well as related server architectures.

History of Mobile Terminals

Renren www.renren.com (formerly known as ), started mobile phone software development in the second half of. At that time, Internet companies on the first and second lines in China had begun to deploy the mobile Internet, however, there are not many products that have been released and available for reference. In particular, SNS are also a new interconnected service, allowing our users to conveniently access SNS on their mobile phones, this makes us hard. In order to quickly launch the first version of the trial, we first chose the javame platform to develop the first mobile client for everyone.

Renren's main businesses include new things, personal homepages (status, logs, albums, messages), friends, insite emails, chats, games, and so on, and around the social graph, if you want to move these businesses to mobile phones, it cannot be completed in a short time, because client-side software differs greatly from browser web pages in terms of display and interaction, the screen size limit of mobile phones also brings great difficulties to the design and is undoubtedly worse. At that time, we selected several common services, new things, personal homepage (status, log, album, and message), friends, insite emails, and Layout Based on the top navigation of the main site, A multi-tag navigation interface is designed. Each tag has a business, and the page jumps to the same origin site. For example:

Figure 1

It seems that this design is very simple and almost perfect, and the code is also very well implemented. Everyone is excited and eager to welcome another miracle of the mobile Internet. Maybe you are just like me and our product manager, if we underestimate all of this, Renren's services are not as simple as chatting software. When our engineers complete their own assigned services and start to process the page jumps between different services, an unknown hunch hangs over the entire team. At that time, rashness led to a serious crisis. As you know, when we access the webpage through a browser, the hyperlink in the page allows you to jump to any page at will, these pages are not necessarily related to the same business. For example, I can directly jump to a friend (cross-tag) from my personal homepage, and return to the previous page through the browser's back button, client software cannot be set as this freedom. How should we handle the redirection of different business interfaces? The redirection that everyone understood at the time did not take into account the problem of retreating between different services at all. In addition, the browser does not need to know which business the next interface is, but the client must know, otherwise, event interaction cannot be processed at all. Technical panic, product manager also panic, seeing the promised delivery time approaching day by day, we still did not come up with a very good way, many attempts failed, some solutions, even we were dizzy when the page was redirected. In the end, javame Client 1.0 of our first version ended in failure.

The first battle was not good, and everyone was not happy. After several months of hard work, we finally decided to release the 1.2 client in Beta form and provide public download, in addition to the photo upload function, other functions may just make us feel usable. The failure of javame makes us feel at our own risk, and we will be defeated. After a period of discussion and analysis, we all agree that we need a mobile browser. Whether on the PC side or on the mobile phone side, the ideal display mode is the browser, so we started to develop mobile browsers. It took us 3 to 4 months to develop our first javame-based browser engine, code: Movie SS (why is this name, later ). For the browser engine architecture, see WebKit, for example:

Figure 2 Alibaba SSBrowser Structure

The blue part is the implementation part of our engine. The red JS, CSS, and plug-in are future plans. From a technical point of view, this architecture looks very beautiful, the module features are clearly divided and highly scalable. We only need to rewrite the render engine to render a common page as any effect we want, unfortunately, we did not apply the browser solution to the official release of the Renren client. The reason is very simple. It is not perfect. We performed a large number of test cases in advance. After the development, we tested the test cases one by one. The final conclusion was that although we expected the performance and XHTML tag support, but the stability and package size did not reach the ideal state: the runtime memory consumption is about 8-10 times the XHTML page size, for example, a 30 k xhtml page is parsed, rendering must have about KB of free memory. If multiple pages are rendered or new pages are frequently rendered, it is very easy to crash (We later found some memory leaks in the Code); in addition, the size of K after packaging is already large for javame mobile phones. In the first half of 1.5, Android released sdks, and the message sent from iPhone to China was everywhere. Obviously, in this industry situation, the management of the company has lost interest in our browser engine program on javame. Our engineers have been rescheduled for new tasks, and the history of guest SS has become a historical one, the browser did not save us.

Reflections in pain

The first half of was the most painful time for us. After more than half a year, we did not release a proud product, but the market was changing rapidly, android came into our field of view with a shining light, and we had to make some adjustments and start to invest in the iPhone and Android camps. We began to reflect on the previous failures. We seem to have gone through two extremes. For the first time, when we thought about the product and technical architecture, we were too hasty and faced a lot of psychological pressure in the future, for the second time, it was a typical case of over-design. Although it was a very challenging and interesting project from a technical point of view, our idea was to first complete the javame platform browser, and then transplanted to other platforms such as Symbian to unify the architecture. However, the mobile Internet market has experienced rapid changes in recent years, and we are not allowed to continue the browser project, regardless of manpower and time.

Why should we unify the architecture?

Renren has a wide variety of services, and the PC end is based on the browser web page mode, which often needs to be optimized and changed regardless of the content or layout, if we migrate all existing services to the mobile phone end in the form of a pure client, when we complete the migration of 5th services, the first two business master sites can have changed, or a service before the client is launched must be compatible. In this case, we can quickly iterate the Client Version to catch up with the business iteration speed of the main site, either we use a browser or a browser-like mode, where all services are placed on the server, which is why we are considering developing the Alibaba SS, and the name is intended to span all mobile terminal platforms.

Can the architecture be unified?

Yes, the browser itself is a very good cross-platform solution. However, the early investment in this solution is very large, and the project execution risk is too high. The services of Renren are mostly implemented on basic dynamic web pages, using a lot of Ajax and flash technologies, we finally gave up the browser solution, and we certainly did not need the unified architecture.

The mountains are exhausted,Liu yinghuaming

Having abandoned the browser solution, we were exhausted. Is there a third solution? Facebook's iPhone app inspired us a lot, as shown in the figure:

Figure 3

From the product perspective, the layout shown in this figure is no different from the design we tried for the first time. Further down, we will find that the biggest difference between this design and the previous design is page Jump, each tag has an independent view stack, which is theoretically infinite. The current top view of the stack allows you to open a new view and automatically store the stack, if the current view is to be deprecated, the content of the previous view saved in the view stack is returned by default. What should I do if the page of tag 1 needs to jump to the page corresponding to tag 2? Is the tag automatically switched? The answer is not practical. labels are only used for business navigation and have independent view stacks. The pages in the view stack can be unrelated to the business. For example: when we use Chrome, we can open multiple different websites or pages on multiple tags at the same time, or open the same website or page, each label has an independent back record. This design is very regular and easy to understand and not dizzy. Now the problem of page Jump and back is well solved. We use the same design, regardless of javame, iPhone, or android client.

Take a look at the present

When our clients use this label + view stack solution, our platforms have basically achieved a unified design and rapid iterative evolution in the existing design. You may have thought that it is a skill to unify the code layer. Maybe you are right, but we will not make such a high-risk attempt. Today, mobile platforms are quite different, from the perspective of the development languages on the mainstream platforms, you may be confused. javame and Android use Java, iPhone uses objective-C, and Symbian uses pure C ++, now Nokia and Microsoft have joined forces with WP7, but WP7 will no longer support C/C ++ development. It focuses on C # + Silverlight. Well, we can only look at it again.

In the next one to two years, mobile Internet will develop at an unprecedented speed. Most internet companies have started or already launched mature mobile terminal solutions, start-ups will also emerge one after another to launch a variety of excellent mobile terminal applications: mobile payment, lbs, instant messaging of the basic Address Book, mobile music, mobile video, mobile phone reading, etc, the iPad ignited the smoke of a tablet. The design of the tablet once again posed a great challenge to us.

Highly Reliable and scalable services

Currently, the mobile Internet is dedicated to services, and powerful server technical support is provided behind the good client user experience.

Business level model

Renren uses javaee technology as its main business solution and basically designs the architecture according to the general javaee model, for example:

Figure 4Renren business hierarchy model

  • The web layer provides Web-based access interfaces based on the rest style and MVC design pattern.

    Renren uses the self-developed web framework rose, which is based on the Spring framework and similar to the ROR framework. It enhances the support for the default conventions of controller encoding and rest-style URLs, this item is currently open-source, for http://code.google.com/p/paoding-rose/

  • The business layer encapsulates the business logic and provides business interfaces for the web layer to operate on the data provided by the data access layer.

    Renren has developed its own SOA framework xoa to support business layer abstraction. This framework, combined with the rose framework, classifies businesses in a REST style, encapsulates messages in formats, and routes them, as shown in the following URL:

    Xoa: // blog.xoa.ren.com/photo/?user-id=/?photo-id}

    This URL indicates a user's photo. The get/Put/post/delete operations correspond to reading, modifying, adding, and deleting corresponding photo resources respectively. That is, the service is provided externally through resource + operation.

    Xoa supports remote calls and supports horizontal scaling by simply adding servers. This framework is currently open-source, so stay tuned.

  • The data access layer encapsulates database access.

    Renren developed its own object-Relation Mapping Framework JADE (Java Database Engine) using the Java language and supports horizontal database splitting. The framework and Rose framework are both open-source and identical.

  • The persistent storage of data in the data persistence layer mainly uses the MySQL database and developed its own massive storage system nuclear.

    Rose, Jade, and xoa are a complete set of integrated solutions. They are widely used in Renren, greatly reducing development costs, it also solves the applicability of javaee technology serving Enterprise Solutions in the Internet field at the framework level.

Scalable high-performance system

Renren has to bear the concurrent pressure of hundreds of millions of PV users every day. Like other large Internet sites, Renren has done a lot of work in terms of server architecture.

High-Performance Data Storage System

Renren has done the following in terms of data storage:

  • Similar to other large Internet sites, MySQL databases are horizontally split to support horizontal scaling.
  • Renren, as the largest SNS website in China, must have a massive storage system to store massive UGC data. The nuclear storage system is born with high performance, high reliability, and scalable massive data storage requirements.

Nuclear's data storage is based on the key-value format. The underlying storage engines such as MySQL/memory, Cassandra, TC, and redis can be used to provide weak Structured Query functions.

  1. High scalability

    A nuclear cluster supports 1 to n (n <264) nodes

  2. High reliability

    The crash of a single node will always affect the system operation, and there is no single point of failure. The system is always writable.

  3. High Performance

    In the case of four nodes and general server configurations, the test data indicates that a single node can access 15862 req/s, and the average time for a single request is only 5 ms.

This article will not detail nuclear. If you are interested, please refer to our technical site.

Scalable High-Performance Service System

The Renren business layer supports distributed and horizontally scalable services.

  • Renren mainly uses the javaee architecture for business development. The IOC and AOP functions provided by spring are good abstractions of Business Object assembly and horizontal separation of concerns. Based on spring and netty, The xoa framework uses Google's spdy protocol as the network transmission protocol. In addition to enjoying the spring bonus, it also provides a network high-performance server environment based on Java NiO. A single xoa service is stateless and idempotent. The xoa client uses Java NiO to maintain TCP persistent connections to backend servers through keep alive, you can monitor the health status of backend servers in real time and distribute user request loads to backend servers. If a single node fails, the service is not affected, as shown in Figure 5:

    Figure 5 xoaServer Load balancer

  • Many key services have extremely high performance requirements, and many Linux operating system features are also required. At this time, Java optimization cannot meet the requirements and needs to be developed in C ++. Renren uses the ice framework to develop this part of the business. It solves the framework and communication problems of Java, C ++ and other languages. Renren is currently using ice to develop a business layer called the middle layer, which mainly solves underlying key business problems with demanding performance requirements such as search and User Friend relationship computing. The O & M mode is similar to that of xoa.

    Like other large websites, the business layer uses memcached as the distributed data cache of the business layer, and divides the cache cluster into multiple pools based on the business, for centralized management, as shown in Figure 6:

    Figure 6 memcached pool

  • On the web layer, use the currently highest-performing servlet container product resin as the HTTP server and use the self-developed Java Web MVC framework rose to distribute user requests. F5 or nginx is used for Server Load balancer. To reduce the overhead of session replication and synchronization, each web server disables the servlet session, that is, each server is stateless. After a single web server fails, the user status will not be lost. The middle layer processes user status tracking in a unified manner.
Support for mobile terminals

The server's support for mobile terminals is mainly implemented through the JSON data interface provided by the HTTP protocol. The server basically adopts the common architecture of Renren:

  • The HTTP web layer implements more MVC abstraction. In addition to HTML-based page views, it also generates feed views that only provide JSON or other data formats.
  • The server uses gzip compression to reduce traffic and reduce user fees.
  • The client builds a rest-style HTTP request, and the Web server sends data to complete remote calls.

The 3g api layer directly targets mobile terminals, provides server access interfaces based on HTTP and other socket protocols, and abstracts the public platforms of the 3G Department at the business layer, as shown in Figure 4:

Figure 7 3G APIArchitecture

In addition, some special work has been done for the characteristics of mobile terminals and the mobile Internet environment with Chinese characteristics:

  • Low-end models have limited computing capability and memory resources, and the API platform has been optimized accordingly.

    • Complex computing servers are completed to reduce the load on mobile terminals. Slice scaling, cropping, and image quality are performed by the server.
    • The data input and output by the client and server are minimized, which can save memory storage. When the data is the same, try to use a small data size and easy to parse format. JSON is used on the API platform, but XML is not used.
  • Transmission traffic is controlled to reduce user fees
    • Nginx enables gzip compression to reduce network transmission traffic.
    • China Mobile's cmwap gateway automatically decompress the gzip stream output by the server, thus making nginx zip compression meaningless. In this case, the API server compresses the output by gzip and then responds to the output as a normal binary stream.
    • In addition to plain text JSON, the API server also supports output in Google protocol buffers format to provide more compact format output.
  • Increase client access speed
    • The API platform supports batch processing operations based on logical time series. It combines network interface calls of multiple APIs into one, reducing the time consumption caused by multiple TCP handshakes, improve the response and display speed of each UI interface of the client.

 

 

 

Original article address:

 

 

Http://www.infoq.com/cn/articles/renren-mobile-arch

 

 

 

 

 

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.