What is the difference between php and java website backend?

Source: Internet
Author: User
What is the difference between php and java website backend? Share To: ------ solution -------------- What is the difference between php and java website backend?

Share:


------ Solution --------------------
Copy and paste the file directly.


In this way, we can look at the following aspects:
I. operating mechanism:
After the Java code is compiled into bytecode, it will be re-compiled into a local code by JIT in the virtual machine. it is rumored that the execution speed can be comparable to that of C ++. after my own test, java is used to implement a simple Memcache protocol cache server running in Java 1.6. compared with memcache itself, the same data volume access time is about, although there is a gap, but it is much better than imagined. Java 1.7 has made a lot of improvements in JIT, and its performance is better than Java 1.6.
PHP implements interpretation of text code directly. even with the opcode cache technology, there is still an insurmountable performance gap. PHP opcode is similar to java class bytecode and is still interpreted and executed.
II. processing concurrency:
Java adopts the multi-thread method for acquiring a single process in concurrent processing. web applications are started with the startup of web server, and requests from web browsers are allocated to idle threads in the thread pool for processing, that is to say, when a request arrives, the process is prepared and the thread is prepared. Java only needs to process the business logic.
PHP adopts a multi-process method for concurrent processing. there is no physical web application concept in the web server. each request is equivalent to an independent application, the process starts with the arrival of the request, and ends with the end of the request. In the Fast CGI environment, there is a process pool technology similar to the thread pool, which greatly improves the performance. However, on the one hand, web server and Fast cgi still need to communicate through socket, resulting in a certain IO loss, and on the other hand, it is difficult to communicate between processes in the process pool, therefore, concurrent processing cannot be compared with Java.
III. database applications:
Java can use the database connection pool technology to save time loss caused by the database connection process.
PHP does not have this benefit because of the second one above.
On the database interface, java has JDBC and PHP has PDO, which are very similar. However, Java has a lot of ORM technical frameworks (such as Hibernate) to make database operations very simple, and the PHP running mode determines that it is a restricted area of ORM (of course it can also be used as an ORM, it is only determined by the degree to which you endure the performance loss caused by ORM ).
IV. cache technology
Java is a single process. many caches can be directly implemented in Java's heap without external tools. of course, there is also a good cache framework, such as Ehcache, because there is no network IO, therefore, the performance is very high.
PHP multi-process single thread determines that it can only use external cache servers, such as Memcache.
5. hot deployment
Java's hot deployment capabilities are weak. it is difficult to fix bugs without stopping services.
PHP natural hot deployment.
VI. development costs
A good Java programmer requires more knowledge reserves, and the development and debugging takes a long time. good web servers are also charged.
PHP and web server are free of charge.
VII. security
This depends on how you define security. if it is code security, it is easy to decompile java class. in this case, the two are similar.
Java has a security configuration mechanism to ensure that some "illegal operations" cannot be executed. in this case, PHP is weak.
However, Java is prone to application downtime due to a BUG, and PHP is much safer.

In fact, Java has many advantages, but only the last three can allow decision makers to use PHP and discard Java.

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.