[Transfer] Experience and difficulties in the development of large-scale Java multi-user mall system

Experiences and Difficulties of Large-scale Java Multi-User Mall System Development


 
I have been engaged in Java enterprise-level development, so I have come into contact with many Java development frameworks. At present, it is an entrepreneurial project of a multi-user mall, because I only specialize in JAVA, there is no way, and there is no need to choose a model. After entering the JAVA world, there are many frameworks to choose from. List a few familiar ones, such as presentation layer struts, spring mvc, jsf, tapestry..., control layer: spring/ejb, ejb don't know if they count, anyway, spring's The author said that he developed spring to compete with ejb, see the classic red book: Expert One-on-One J2EE Development without EJB, which is what I just learned about spring. Data persistence layer: hibernate/ibatis/jdbc, in the final analysis is jdbc, this must be mastered. The following is a comparison of the selection of each level. In addition to these levels, of course, there are other frameworks to choose from. Java has too many frameworks. Friends who have just entered the door are likely to have lost their eyes. However, I advise all new friends to pay attention to the basics of Java. All frameworks are transformed from these foundations, and the core technologies of Java for web applications are servlet/jsp/jdbc/ (ejb should be Forget it, I see that many large-scale applications are inseparable from JMS/EJB, etc.), if you have time, study the code of open source frameworks such as JDK, Spring, Hibernate, Tomcat, etc., which reflect many design patterns, code specifications, etc., It will definitely bring you a technological advancement. I just started watching it myself, and I feel that the benefits are not shallow. If we only know how to apply the framework without knowing its underlying meaning, it will only stay at the level of programmers. Therefore, if we develop in the direction of architects, Java will become more and more important. Do the bottom. Let me explain the background of the project first, otherwise I don't know why I chose this. Now e-commerce is getting more and more popular, and advertisements on Taobao and Jingdong have penetrated into every corner of life. Although the group buying network is not very prosperous recently, there are also many e-commerce companies that have closed their doors. But we have reason to believe that e-commerce will also be on the rise in the next decade. The reasons are as follows:  


 
 
    1. Some studies have said that the proportion of e-commerce in the United States is much larger than that in China. The popular things in China's IT industry are often later than those in foreign countries. There is still a lot of room for development of e-commerce in China.     2. There are more and more people online in China, and now no child can't use a computer, even the poor second generation. And older people may not necessarily     3. Online shopping does bring convenience to people's lives, especially when the economy is not good, it can provide you with cheaper and suitable products.     4. A company of a certain size in China should not be satisfied with opening a store on Taobao/Paipai and other websites. The success of JD.com/Casual.com will stimulate others to join the competition in this industry.     5. Taobao's practice of raising the threshold may crowd out some small merchants. It is not ruled out that these merchants have the need to establish independent websites, but to solve the problem of credit and traffic first.     The above reasons are from personal YY, don't take it too seriously, anyway, we just want to carry out a business project led by the mall. OK, well, let's start analyzing the competitors of the current independent mall system.     At present, the php mall occupies most of the market, followed by the .net mall, and the java mall has few good ones. In order to exclude the suspicion of advertising, there is no name of the mall system here. Why is there such a phenomenon? In fact, the advantages of the java language are very obvious. The banking and telecommunications industry is basically dominated by java. This is what I have seen in my work experience. Including Taobao/Jingdong, there is a tendency to move closer to java. Since the architecture of the java language itself is more suitable for large-scale applications, we have reason to believe that the java mall will have more room for development. We have to solve the problem of high Java development cost, so good frameworks and development models are indispensable.  
 
 
 
 
     
 
     
 
     
    Therefore, we wrote a Java multi-user mall system based on B2C and followed up with C2C. The previous C is actually composed of many Bs, which can be understood as B2B2C, similar to the Taobao mall model. In this way, we can meet the needs of B2C and those of C2C, and avoid the competition of mature malls in the market. One of the advantages here is that it can be operated by local merchants in combination with Taobao and the people's network. That is, each city or university finds an agent to operate it alone, and the data is kept on their server alone. Our main station only retains a small amount of data. For example, single sign-on, unified community, unified search experience, etc. This is a big project, and it has not been able to progress for the time being, but the future is limitless. A lot of people have already consulted a similar plan, so that we can gather the strengths of hundreds of companies to compete with some large shopping malls, that is, the B2B2C model. It is a good idea, but it needs powerful people to promote it. It will appear from similar stores.     Too much background to talk about, back to the topic. At present, the system has achieved some achievements, but it has also encountered many problems. I will share it with you here.     The best framework combination in my mind is:     presentation layer: spring mvc 3.1 + annotation     control layer: spring 3.1     persistence layer: hibernate 3.6 + jdbcTemplate     background list control: displaytag 1.2     Ajax framework: DWR 3     JS framework: Jquery     caching mechanism: spring 3.1 cache + ehcache/memcached     static mechanism: Freemarker static / spring mvc pseudo static     page technology: EL + JSTL +JSP  
     
 
     
 
 
 
 
 
 
 
 
 
 
    Security framework spring security     search engine: Lucene     Chinese word segmentation: IKAnalyzer     Template engine: apache tiles 2.22  <!--StartFragment -->  
 
 
 
   
kvm, redhat6.4, 4core, 4g, JVM heap 2g; apache is the reverse proxy for http and https, memcache is for tomcat group session management, activemq is for cache synchronization, postgresql read-write separation is not optimized
Add sharding to support large amounts of data     The above frameworks all use the latest frameworks, and may be replaced if there are updated features.     Required for deployment view:     Database: mysql     Web server: apache under windows, ngnix under linux     Application server: Tomcat     Other distributed technologies, such as EJB/web service/JMS, etc. are not used, if you change the deployment scheme or need to integrate Other systems may be introduced.     A small and medium-sized deployment solution is 1 Web server + 2 Tomcat servers + 1 memcached server + 1 image server + 1 database. This solution is convenient for continuous system upgrades and requires less investment. Of course larger solutions require more servers and more optimization actions on the database. The most economical way is to run all the above services on one server. This is not impossible. A 1G memory can already handle a lot of traffic. In those cheap JSP spaces, as long as there is 256/512M memory, you can run, there are big and small running methods.     The following is a simple comparison of the more concerned frameworks:     1 spring mvc vs struts2
     
 
     
 
 
 
 
     
 
     
 
 
    

 
     
 
    We originally used struts1.3 to develop, the struts layer is very thin, just used to receive page parameters and get database data and print it to the request to display the page. It stands to reason that it should be upgraded directly to struts2, but after reading the annotation version of spring mvc 2.5, struts2 was abandoned. Spring mvc can make it easy for me to get data from the page, and it adopts very little configuration and has strong flexibility , after reading struts2, I feel that they are all the same ideas, so why should I introduce more jars..     2. hibernate va jpa ibatis     Jpa is very similar to Hibernate, I personally feel that it is not as flexible as hibernate, and hibernate has advantages in rapid development Yes, plus the cache can partially make up for the performance loss, and try not to do complex associations with his configuration.     In addition, you can use more places on top of jdbcTemplate to improve performance.     3. DWR vs Jquery     DWR is a good bridge between js and the background java code, especially with spring .     4. spring 3.1 cache + ehcache/memcached      spring 3.1 supports cache directly, this time the second level cache of hibernate can be retired. If ehcache is selected on a single machine, memcached is used in the cluster mode. Memcached is a remote call, and performance will inevitably suffer.     5. JSP vs freemarker velocity  
 
 
 
 
 
 
 
 
    Since JSP has JSTL, I no longer use struts tags. After adding EL, I have not found a reason to use freemarker velocity. In addition to being static, it seems that JSP can also be static. I have not studied this deeply. Objections can be raised.     6. apache tiles vs sitemesh     Because I learned struts, I am familiar with tiles, and now it also supports fuzzy matching. I read some online comments that the performance will not be much different, sitemesh3 may be better, it is better to use familiarity. However, none of them can achieve the template effect that takes effect in real time. Who can tell me how to do it in java?     7. There is no suspense about the rest. Since more free jsp space supports mysql and tomcat, these two are our priority to support, although we also support oracle and so on.     Questions:     1. The template technology lacks flexibility. At present, there are many templates available in Php's large-scale mall system, not all of which are developed by the official itself. This is where the Java mall needs to learn from the PHP mall. Because java is built in mvc mode, there are java, jsp, html, etc., java class needs to restart the server to take effect, and it is difficult to write everything in a directory and copy it to the server like php. What good ideas can achieve this effect, I have investigated apache tiles/sitemesh/freemarker/velocity, etc., but I can't think of a way. . . It can only be done with built-in templates for users to choose. To get to the point where everyone can make templates, the code and documentation need to continue to be improved and open sourced.     2. The B2B2C model requires a lot of human and material resources and is not yet mature. We need people with strength and experience to join us.  
 
 
 
     
 
 
 
    3. The cost of java development is higher. Through the integration of the framework and the default agreement, the use of the background code has been fixed, and the front page is more time-consuming. But how to reduce the overall development difficulty and create a Java brand mall is very challenging and difficult. Reprinted from: http://onecan.iteye.com/blog/1333520  

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326787003&siteId=291194637