search

Home  >  Q&A  >  body text

node.js - 用node开发一电商网站,好不好,和php比较有什么利弊,求解答

用node开发一电商网站,好不好,和php比较有什么利弊,求解答

黄舟黄舟2782 days ago815

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 11:30:51

    It is not recommended to use node to write. Because the characteristic of node is biased towards performance, while the characteristic of php is to focus on logic.

    If you develop an e-commerce website. It requires more logic. For example, categories, products, comments, orders, etc. are all business logic.

    Platform model features

    PHP’s (fpm) model is a thread-based synchronization model. So you can spend a lot of energy on how to handle your business logic. Instead of messing with thread synchronization and resource preemption like Java. Not to mention blocking, asynchronous processes, and exception management like node. This model is crude for performance but very effective for business development. The process model is very effective in low-concurrency scenarios, without problems caused by memory leaks and low robustness. Because the end of a thread means that all occupied resources are released. PHP uses C as an extension carrier to ensure computing and IO performance.

    node is based on a single-threaded asynchronous model. So there are more things you need to consider. Asynchronous process control, single thread is fragile, and master/slave is required to enhance robustness. Also consider exception handling under asynchronous conditions. Single-threading also means that any low performance (time-consuming calculations, etc.) and blocking cannot be tolerated.

    Frameworks and Class Libraries

    The PHP community is developing better and better now. There are frameworks such as symfony2 and laravel that save you from having to reinvent the wheel yourself. Various third-party platforms now provide support for PHP. Moreover, the above two frameworks provide features such as dependency injection, ORM, modular development, and resource management. You can easily develop web programs with complex business and good scalability. There is also good support for REST. Scaling out is also great.

    Node only has connect in the web development framework, express is more mature, and express is not an mvc framework, to be precise, it is an http business layer framework. This means that you need to spread some energy to deal with parts other than business logic, such as how to layer, what kind of ORM to choose, what kind of template engine to use, etc. Moreover, many express functions require support from middleware, such as cookies, session, json, crsf, etc. Controlling express well requires an in-depth understanding of http. REST support is relatively bare. It requires the use of third-party class libraries to support elegantly. Building web programs with complex business scalability through express requires developers to not only have strong JS skills and experience in developing complex businesses, but also have the ability to maintain elegant and scalable code.

    So I personally think that nodejs is not suitable for developing products with the following properties

    1.Prototype product
    2. Products with no performance requirements
    3. More calculations
    4. The overall js ability in the team is relatively weak

    So your problem accounts for at least 1,2. Using node is not recommended.

    Although node is beautiful, it needs to be used with caution, because it has many pitfalls that developers need to fill. I personally think nodejs is still too young compared to other platforms, which also means that we need to help node grow up. Become a powerful platform that combines high performance and ease of use.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:30:51

    If the subject is a programmer who is very familiar with js, it is excellent to use node. It unifies the language and can take into account both development speed and performance.
    If it is done by a team, you should also consider whether the teammates can accept node. PHP may be more suitable.
    It is meaningless to simply discuss the feasibility of theory, Just do it!

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:30:51

    Because of the characteristics and flexibility of Node, the development ecosystem has become relatively mature in the past few years. I have learned to avoid the big calculation part, and it is still suitable to do e-commerce projects with Node.

    I have a question: Is it appropriate to use mongodb or Mysql for Node’s e-commerce database?

    reply
    0
  • Cancelreply