Home > Backend Development > PHP Tutorial > Since JSP is suitable for large websites, why is Baidu's homepage still written in PHP?

Since JSP is suitable for large websites, why is Baidu's homepage still written in PHP?

PHP中文网
Release: 2016-07-30 14:02:13
Original
4836 people have browsed it

In general, Java far exceeds PHP in terms of technology. Regardless of the cost issue (which should be affordable by large companies), why is Baidu’s homepage not written in JSP? Doesn’t real-time search need to be distributed? And some results will be automatically loaded when typing.

Reply content:

Can you send this book out?
I want to block this publisher. laxative.
First of all, let’s see if the Baidu homepage really uses php. baidu,com/index.php is undoubtedly open, but we also know that it can be opened. By setting the routing settings at the HTTP service software level, this address is actually parsed to other content, such as static files or other CGI-processed resources. For example, pseudo-static implementation is to route html to other dynamic resources, such as php (taking into account caching , it may also be a static resource), so it is impossible to determine whether it is PHP based on this alone.
So use chrome to open Baidu,

Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

The information we need to see is the content boxed in red. First we see that the value of Sever is set to bfe/1.0.8.14, the server field in the http header Usually it is the name of the http server, such as Zhihu:
Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

Qnginx. I guess it may be a magic modification of Nginx. Baidu's bfe is either its own product, or it may have changed the source code of nginx or the like. For this, see What server is used on Baidu's homepage?
Then let’s take a look at the cookie content set in setcookie. We know that generally the cookies set by php itself will have fields similar to the following:
Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

However, let’s take a look at Baidu’s:
Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

There are many Token fields named after Baidu, and there are no cookies that come with php, nor It doesn't look like the cookies that come with many languages/frameworks, which will be discussed later.
Let’s take another look at a field in the request on Baidu’s homepage:
Since JSP is suitable for large websites, why is Baidus homepage still written in PHP?

HPHP, which is HHVM. If Baidu doesn’t use a proxy

or modify the header or HHVM at the HTTP server level (Baidu probably won’t either If you are so free to change something that is not confidential), then you should use PHP. So let’s explain why we don’t use the default one (the default cookie will have the PHPSESSID field)

session_start()
Copy after login

Facebook is still written in PHp, as are Sina Weibo and Tencent. Do you still use Python on Zhihu? Regardless of whether the information in the title post is accurate or not
The PHP on Baidu’s homepage is just for rendering results. The search engine itself should not be based on PHP. Holy crap. .
As a Baidu employee, I saw this question in the middle of the night and instantly became energetic. .
One is smiling, and the other is unable to help but complain deeply deep in his heart. .
Are you a student? Or that I have never been exposed to very large projects. If you have the opportunity to go to a big company and get in touch, you will understand that this question is really stupid. .
The company has been attracting bad guys lately, so I’ll stay anonymous because I’m too lazy to argue with people.

First of all, PHP can do page rendering, but if you have ever worked on a framework, you should know that this URL request will be distributed, and there is a lot of room for independent operation wherever it is distributed.

First of all, intermediate distribution is definitely not as simple as you think. There are hundreds of millions of requests every day, and there will definitely be various caches, clusters distributed across the country, etc.
Besides, in order to speed up the loading speed of the home page, it must be changed to C optimization.

Then, when you enter, it will be distributed to the corresponding retrieval cluster.
The code for this is C++, why? Because I changed it myself. .
This is divided into many modules. .

For example, the process from when you input a word into the search box to when the data is retrieved is indeed very simple. .

The crawler crawls the data and then builds an index based on the data.
The problem is that it’s very complicated to do the best in every detail.

How can you be more accurate when segmenting words? Directly use an open source library? Are you kidding me? It is best to have a professional team in charge of this, and it is more research-oriented, so we need to recruit a lot of PhDs and graduate students to do it.
Okay, now that the words have been divided, we need to get the index.
How to find the corresponding data among hundreds of billions of results within milliseconds?
Then sort them and return the results the user wants? Sound complicated?

Actually, it’s not troublesome to say this. Just zip it upside down and make a good cache. In fact, 90% of the searches are 10% of the words.
However, the amount of data is a bit large, so the entire index may not be placed in the memory, and part of it must be placed on the hard disk. The problem is that the hard disk is slow. Can we do some optimization?

Then how to choose the most suitable one for users? There are many optimization points in this strategy, and if you do it well, you will gain a group of people.

This is just retrieval.
In terms of crawlers, the data we crawl down every day is beyond ordinary people’s imagination. How to crawl efficiently can provide more reliable data to the retrieval end.
This is done by a bunch of people again.

But the problem comes again, you find that the amount of data is too large, how to save this data? How to manage better?
This doesn’t all require a lot of manpower to do. .

Oh, and Fengchao, this one is hacked by you every day.
Because it involves money, a lot of manpower is invested in various strategies and data optimization.

So, I saw your question. . . .
I really think, what the hell, let’s get into the next super-large project.
You will find that basically there is a language that is most suitable for you at a certain moment, so just use it.
Baidu only has a few people at the beginning, and it will be good if it has hundreds of thousands of users. Just go to a website and use it quickly, and there is no need to consider efficiency. Back-end indexing, when there was no Hadoop at the beginning, there were always problems with machine maintenance, so I sent a few people to do manual maintenance every day.
Then, later I found that php was not easy to use, so I thought about optimization.
Anyway, once the business is established and the money is made, if a bunch of talented people work hard, they will definitely be able to come up with a solution.

Of course, search engines are still very technically demanding. Now that various frameworks and cloud computing have matured, they are much easier to do. In the past, there were indeed huge technical barriers to doing so.
At least dozens of times more difficult than setting up a website.

But language is definitely not the biggest problem. .

You will find that you are still struggling with language here. Isn’t it stupid? The database interface provided by php is not uniform. . . . . . How many years ago. . . It was solved as soon as pdo came out. Many of the opinions expressed by the question author are one-sided and outdated. Generally speaking, PHP is now the dominant player in the WEB business. Although jsp has advantages in large-scale businesses, in general, php can already compete with it in many aspects. . besides. . . Who told you that Baidu’s search engine is PHP. . . The homepage is just a layer of skin, no matter what you use to write on it, there won’t be much difference. Of course, search is distributed, but it is provided as a service and has nothing to do with the homepage. As for automatically loading some results, JS sends a request, and the background is also provided as a service. As for the backend services, I don’t know how Baidu implements them. There are various languages ​​and solutions to choose from, just choose the one that suits you. There are indeed many search solutions based on Java, but it does not mean that it cannot be done without Java. There is no upgrade or replacement relationship between php and jsp. It can only be said that each has its own strengths. The reason why php seems weak is that most people who write php in China are weak. Even if Facebook switches to PHP before hhvm, it can easily support 1 billion+ requests every day, and not many servers are used. There is no specific data, but some people speculate that the php stand-alone qps of fb at that time was around 3000-5000, which was not an order of magnitude different from the jsp stand-alone. The peak performance of a single PHP server in a company I work for is around 700 qps. This is mainly due to the confusing code writing and poor performance. Taobao's sharing shows that the single-machine QPS in some PHP business clusters is only 200-300. This can only mean that it is a human problem. Finally, it is recommended to read more articles on architecture. The answers to such questions are naturally contained in them. Do you think Baidu search engine only has one homepage? PHP is the most beautiful language in the world Oh my god~

The above is that since JSP is suitable for large websites, why is Baidu’s homepage still written in PHP? For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template