Table of Contents
Reply content:
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?

Jul 30, 2016 pm 02:02 PM

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)!


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles