面试Nginx的几个常见问题(
生活随笔
收集整理的這篇文章主要介紹了
面试Nginx的几个常见问题(
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1、Nginx 服務器上的 Master 和 Worker 進程分別是什么
Master 進程:讀取及評估配置和維持 Worker 進程:處理請求?
2、怎么添加模塊?
Firstly, you have to select the Nginx module during the compile. Runtime selection of module is not being supported by the Nginx server.在編譯過程添加模塊
?
3、什么是 C10K 問題?
C10K 問題是指無法同時處理大量客戶端(10,000)的網絡套接字。?
4、在 Nginx 中,如何使用未定義的服務器名稱來阻止處理請求??
只需將請求刪除的服務器就可以定義為: Server {listen 80;server_name “ “ ;return 444; }?
5、Nginx和Apache的區別?
Firstly, Nginx is an event-based web server and Apache is a process-based server.1、Nginx是事件驅動,Apache是過程驅動
Nginx is best known for its speed and Apache is best known for its power. Nginx is the best when it comes to memory consumption and connection whereas Apache is not best in this category. In Nginx, a single thread is handling all of the requests whereas in Apache single thread handles a single request. Nginx is best when you want the load balancing. But Apache will refuse the new connection when traffic reaches the limit of the process. Apache provides lots of functionality as compared to Nginx.
更為通用的方案是,前端 nginx 抗并發,后端 apache 集群,配合起來會更好。
?
6、Nginx是什么語言寫的?
C語言?
7、Nginx的負載均衡策略有哪幾種?
| 輪詢 | 按照時間順序,逐一分配到不同的后端服務器 |
| 加權輪詢 | weight值越大,分配到的訪問幾率越高 |
| ip_hash | 每個請求按訪問IP的hash結果分配,這樣來自同一個IP的請求固定訪問一個后端服務器,可以解決分布式session問題,但不是最優的解決辦法,另一個即集中式session存儲校驗,將session放到redis集群當中。 |
| url_hash(第三方) | 按照訪問的URL的hash結果來分配請求,使一個URL始終定向到同一個后端服務器 |
| less_conn | 最少連接數,哪個機器連接數少,就分發 |
| fair(第三方) | 按后端服務器的響應時間來分配請求,響應時間短的優先分配。 |
8、如何設置在81端口上運行nginx? 修改nginx.conf里的端口號
?
參考:
https://www.onlineinterviewquestions.com/nginx-interview-questions/
https://www.jianshu.com/p/19d0516ea29e
https://segmentfault.com/a/1190000010677483
轉載于:https://www.cnblogs.com/roostinghawk/p/11073511.html
總結
以上是生活随笔為你收集整理的面试Nginx的几个常见问题(的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux后台运行和关闭程序、查看后台任
- 下一篇: C# 不能从数据库更新实体