标签搜索
全栈-04-后端-1
程序员的自留地

全栈-04-后端-1

fiora
2026-10-21 / 0 评论 / 13 阅读
本段 803 题 | 来源:fullstack + general + design | 知识点:后端

1. 单元测试(Unit Testing)与集成测试(Integration Testing)有什么区别?

  • 知识点: 后端 / 测试 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: unit-testing, integration-testing, testing-types)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 695cc0361da553795622a853 | 官方: 是 | 付费: 否

答案:

TL;DR单元测试(Unit Testing)验证单个模块/组件;集成测试(Integration Testing)验证多个模块组合后能否正确协作。
单元测试(Unit Testing)是一种测试方法,开发者测试单个组件或模块,通常在开发阶段进行,目标是在最小代码单元中发现错误并尽早修复。
相反,集成测试(Integration Testing)是将多个单元或组件组合起来进行测试,目的是验证这些组件在组合后能否正确工作。

2. 单元测试(Unit Test)、集成测试(Integration Test)和端到端测试(End-to-End Test,E2E)有什么区别?

  • 知识点: 后端 / 测试 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: Unit Test, Integration Test, E2E, Testing Pyramid)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: general
  • id: 695cd80b1da5537956265218 | 官方: 是 | 付费: 否

答案:

TL;DRUnit 测试(Unit Testing)单个函数或组件,Integration 测试(Integration Testing)多个模块协作,E2E 测试(End-to-End Testing)整个系统从用户角度走完整流程。
Unit- 范围小:单个函数/组件。

  • 速度快,依赖少。
  • 通常会 mock 外部依赖。
    Integration- 范围中:多个模块组合。
  • 验证模块之间接口是否正确。
  • 可能包含真实 DB/API 或部分 mock。
    E2E- 范围大:用户完整流程(登录、下单等)。
  • 最接近真实环境。
  • 最慢、最贵,但能覆盖真实风险。

3. 什么是客户端-服务器(Client-Server)架构?它的核心思想是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: client-server, request-response, centralized-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: general
  • id: 695e01071da553795636b4f9 | 官方: 是 | 付费: 否

答案:

TL;DR客户端-服务器架构(Client-Server Architecture)是一种计算模型:多个客户端(用户或设备)通过网络向一个集中式服务器发起请求,服务器负责管理资源、处理请求并返回结果。客户端负责发起请求并处理响应(如渲染界面、展示数据)。
核心思想- 客户端(Client):发起请求并负责展示/交互,例如浏览器、手机 App、桌面应用。

  • 服务器(Server):集中管理资源并处理业务逻辑,响应多个客户端请求。
  • 网络(Network):客户端与服务器之间的数据通信通道。
    典型例子当你用浏览器打开网站时,浏览器发送请求给 Web Server(Web服务器),服务器返回 HTML/CSS/图片等资源,浏览器再渲染页面。

4. 客户端-服务器架构(Client-Server Architecture)是如何工作的?请描述它的请求-响应流程(Request-Response Flow)。

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: request-response, client-request, server-processing)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: general
  • id: 695e01071da553795636b56b | 官方: 是 | 付费: 否

答案:

TL;DR客户端-服务器(Client-Server)模型基于请求-响应(Request-Response)机制:客户端发送请求,服务器处理并返回响应,客户端再处理响应(渲染或展示)。
流程步骤- 客户端发起请求:请求网页、查询数据、下载文件或调用 API(Application Programming Interface)。

  • 服务器处理请求:读取数据库、执行业务逻辑或生成动态内容。
  • 服务器返回响应:把数据/服务结果返回客户端。
  • 客户端处理响应:浏览器渲染页面,App 展示数据等。

例子登录网银时,客户端提交账号密码,服务器验证后查询账户数据,再返回给客户端显示。

5. 云领域(Cloud Computing)中 API(Application Programming Interface)的好处是什么?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: Integration, Automation, Interoperability)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: general
  • id: 6960ca4a0e32007ea0d2f2aa | 官方: 是 | 付费: 否

答案:

核心答案云领域中 API(Application Programming Interface)的好处包括:

  • 不需要从零写完整程序(复用云能力)
  • 便于应用之间通信
  • 容易创建应用并与云服务联动
  • 以安全方式无缝连接两个应用

6. String(字符串)类的常用方法都有那些?

  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 (主题: java;标签: String Methods, API)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 6965e90dfa809e6d3887808f | 官方: 是 | 付费: 否

答案:

答案indexOf()(索引查找):返回指定字符的索引。
charAt():返回指定索引处的字符。
replace():字符串替换。
trim():去除字符串两端空白。
split():分割字符串,返回一个分割后的字符串数组。
getBytes():返回字符串的 byte(Byte)类型数组。
length():返回字符串长度。
toLowerCase():将字符串转成小写字母。
toUpperCase():将字符串转成大写字符。
substring():截取字符串。
equals():字符串比较。

7. 为什么要使用 spring(Spring)?

  • 知识点: 后端 / 编程语言基础 (主题: spring, java;标签: Spring, IoC, AOP)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 6965f11efa809e6d38885cb7 | 官方: 是 | 付费: 否

答案:

答案1.简介
目的:解决企业应用开发的复杂性
功能:使用基本的JavaBean(JavaBean)代替EJB(EJB),并提供了更多的企业应用功能
范围:任何Java(Java)应用
简单来说,Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器框架。
2.轻量
从大小与开销两方面而言Spring都是轻量的。完整的Spring框架(Spring Framework)可以在一个大小只有1MB多的JAR文件(JAR File)里发布。并且Spring所需的处理开销也是微不足道的。此外,Spring是非侵入式的(Non-invasive):典型地,Spring应用中的对象不依赖于Spring的特定类。
3.控制反转
Spring通过一种称作控制反转(Inversion of Control,IoC)的技术促进了松耦合。当应用了IoC,一个对象依赖的其它对象会通过被动的方式传递进来,而不是这个对象自己创建或者查找依赖对象。你可以认为IoC与JNDI(Java Naming and Directory Interface)相反——不是对象从容器中查找依赖,而是容器在对象初始化时不等对象请求就主动将依赖传递给它。
4.面向切面
Spring提供了面向切面编程(Aspect-Oriented Programming,AOP)的丰富支持,允许通过分离应用的业务逻辑(Business Logic)与系统级服务(例如审计(Auditing)和事务(Transaction)管理)进行内聚性的开发。应用对象只实现它们应该做的——完成业务逻辑——仅此而已。它们并不负责(甚至是意识)其它的系统级关注点,例如日志(Logging)或事务支持。
5.容器
Spring包含并管理应用对象的配置和生命周期,在这个意义上它是一种容器(Container),你可以配置你的每个bean(Bean)如何被创建——基于一个可配置原型(Prototype),你的bean可以创建一个单独的实例或者每次需要时都生成一个新的实例——以及它们是如何相互关联的。然而,Spring不应该被混同于传统的重量级的EJB(Enterprise JavaBeans)容器,它们经常是庞大与笨重的,难以使用。
6.框架
Spring可以将简单的组件配置、组合成为复杂的应用。在Spring中,应用对象被声明式地组合,典型地是在一个XML(Extensible Markup Language)文件里。Spring也提供了很多基础功能(事务管理(Transaction Management)、持久化框架(Persistence Framework)集成等等),将应用逻辑的开发留给了你。
所有Spring的这些特征使你能够编写更干净、更可管理、并且更易于测试的代码。它们也为Spring中的各种模块(Module)提供了基础支持。

8. String 类的常用方法有哪些?

  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 (主题: java;标签: String, API)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 6967260afa809e6d38a20a4d | 官方: 是 | 付费: 否

答案:

答案

  • length():获取字符串长度。
  • charAt(int index):获取指定索引位置的字符。
  • substring(int beginIndex, int endIndex):截取子串。
  • indexOf(String str):返回指定子串第一次出现的位置。
  • trim():去掉字符串首尾空格。
  • replace(char oldChar, char newChar) / replace(CharSequence target, CharSequence replacement):替换字符或子串。
  • split(String regex):按正则表达式拆分字符串。
  • toLowerCase() / toUpperCase():转为小写/大写。
  • getBytes():按平台默认字符集将字符串转为字节数组(也可指定字符集)。

9. 说一下堆栈(Stack)的区别?

  • 知识点: 后端 / 操作系统与网络 / 算法与数据结构 / 编程语言基础 (主题: jvm, java, memory;标签: JVM, Heap, Stack, 内存模型)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 6967570cfa809e6d38a7d150 | 官方: 是 | 付费: 否

答案:

答案

  • 功能方面:堆是用来存放对象的,栈是用来执行程序的。
  • 共享性:堆是线程共享的,栈是线程私有的。
  • 空间大小:堆大小远远大于栈。

10. 队列(Queue)和栈(Stack)是什么?有什么区别?

  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 (主题: java, data-structure;标签: Queue, Stack, FIFO, LIFO, Deque)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 6967570ffa809e6d38a7d38b | 官方: 是 | 付费: 否

答案:

答案
队列和栈都是被用来预存储数据的。

队列允许先进先出(First In First Out,FIFO)检索元素,但也有例外的情况,Deque(Double Ended Queue)接口允许从两端检索元素。

栈(Stack)和队列(Queue)很相似,但它运行对元素进行后进先出(LIFO, Last In First Out)进行检索。

11. 说一下 JVM(Java Virtual Machine)调优的工具?

  • 知识点: 后端 / DevOps/云 / 编程语言基础 (主题: jvm, java, monitoring;标签: JVM调优, jconsole, jvisualvm, 监控)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 69675719fa809e6d38a7e266 | 官方: 是 | 付费: 否

答案:

答案
JDK(Java Development Kit)自带了很多监控工具,都位于 JDK 的 bin 目录下,其中最常用的是 jconsole(JConsole)和 jvisualvm(Java VisualVM)这两款视图监控工具。

  • jconsole:用于对 JVM 中的内存、线程和类等进行监控;
  • jvisualvm:JDK 自带的全能分析工具,可以分析:内存快照、线程快照、程序死锁、监控内存的变化、gc 变化等。

12. Spring MVC(Model-View-Controller)的主要组件有哪些?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, spring-mvc;标签: Spring MVC, Components)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 69685279fa809e6d38b9fad0 | 官方: 是 | 付费: 否

答案:

答案- 前端控制器 DispatcherServlet(DispatcherServlet)。

  • 处理器映射器 HandlerMapping。
  • 处理器 Controller。
  • 模型和视图 ModelAndView。
  • 视图解析器 ViewResolver。

13. @RequestMapping 的作用是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, spring-mvc;标签: Spring MVC, Annotations, RequestMapping)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 69685279fa809e6d38b9fad4 | 官方: 是 | 付费: 否

答案:

答案将 HTTP(HyperText Transfer Protocol)请求映射到相应的类/方法上。

14. @Autowired 的作用是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, spring-mvc;标签: Spring, Dependency Injection, Autowired)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 69685279fa809e6d38b9fad8 | 官方: 是 | 付费: 否

答案:

答案@Autowired 它可以对类成员变量、方法及构造函数进行标注,完成自动装配(Autowiring)的工作,通过@Autowired 的使用来消除 set/get 方法。

15. 如何查询某个玩家的排名与分数?返回结构里哪些字段最关键?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design, api, redis;标签: GET, rank, leaderboard)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dd4b6e6ae93548e947bae | 官方: 是 | 付费: 否

答案:

答案可提供 GET /players/:player-id,服务端从 Redis 获取 rank/score(必要时补全玩家信息),返回 player_id、player_name、score、rank,以及 updated_at 方便客户端判断数据新鲜度;配合 cache-control(Cache-Control,如 max-age=5)控制短缓存以兼顾实时性与成本。

16. 如何获取 Top N(例如 Top 10)排行榜?为什么要把 count 做成参数?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design, api, redis;标签: Top N, leaderboard, API design)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dd4b6e6ae93548e947bb1 | 官方: 是 | 付费: 否

答案:

答案可提供 GET /leaderboard/top/:count。将 count 参数化可复用同一接口支持不同展示位(Top 10、Top 100、活动榜等),并方便灰度与 A/B 测试。服务端通常从 Redis Sorted Set(有序集合)做 ZREVRANGE(ZREVRANGE)+ WITHSCORES 获取排名区间,同时返回 updated_at 与 total 方便前端渲染。

17. 什么是客户端-服务器(Client-Server)架构?它解决了什么问题?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: client-server, architecture)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de86e623565038f408e6d | 官方: 是 | 付费: 否

答案:

答案客户端-服务器(Client-Server)架构是一种计算模型:多个客户端(浏览器、App、桌面程序等)向中心化的服务器发起请求,服务器负责处理请求、管理资源并返回结果。
它把“发起请求/展示界面”的职责放在客户端,把“业务处理/数据管理/资源控制”的职责集中在服务器,便于统一运维、权限与数据管理。
这种分工让系统可以服务大量用户并持续演进:服务器可通过垂直扩容(Vertical Scaling,更强机器)或水平扩容(Horizontal Scaling,更多实例)应对增长,同时客户端(Client)保持轻量、易分发。

18. 客户端-服务器架构(Client-Server Architecture)的核心组件有哪些?各自负责什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: client-server, architecture)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de871623565038f4090fe | 官方: 是 | 付费: 否

答案:

答案典型组件包括 Client(客户端)、Server(服务器)、Network(网络)三部分。Client 是发起请求的一端(如浏览器/移动端),负责用户交互与结果展示。
Server 是处理请求的一端,负责执行业务逻辑(Business Logic)、访问数据库(Database)/文件等资源,并把结果封装成响应(Response)返回。
Network 是通信介质(互联网/内网),承载请求与响应的数据传输,常见协议(Protocol)包括 HTTP/HTTPS、WebSocket 等。

19. 客户端-服务器模型(Client-Server Model)是如何工作的?请用“请求-响应”(Request-Response)流程描述。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: request-response, client-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de875623565038f409661 | 官方: 是 | 付费: 否

答案:

答案客户端先向服务器发送请求(Request),请求可能是获取网页、查询数据、下载文件或调用某个服务。
服务器接收请求后进行处理:校验权限、执行业务逻辑、读取/写入数据库或调用下游服务(Downstream Service),然后生成响应(Response)。
服务器把响应返回给客户端,客户端再解析并展示结果(比如渲染页面或在 App 中展示数据)。整体是典型的 request-response(请求-响应)交互闭环。

20. 两层(Two-tier)架构是什么?适合什么场景,有什么典型瓶颈?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: two-tier, client-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de875623565038f409699 | 官方: 是 | 付费: 否

答案:

答案两层架构中,客户端直接与服务器交互,服务器通常同时承担业务逻辑与数据管理(甚至直接是数据库)。
它实现简单、部署成本低,适合小规模系统、内部工具或并发(Concurrency)不高的应用。
典型问题是扩展性较差:随着客户端数量增长,单一服务器容易成为性能瓶颈(Performance Bottleneck),也更难做安全隔离与统一的业务治理。

21. 三层(Three-tier)架构相对两层多了什么?它带来哪些收益?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: two-tier, client-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de875623565038f4096d1 | 官方: 是 | 付费: 否

答案:

答案三层架构在客户端与数据层(Data Layer)之间新增了应用层(Application Layer,也叫业务逻辑层/应用服务器),把业务逻辑从数据服务器中剥离出来。
这种分层让职责更清晰:客户端专注展示,应用层负责业务与接口,数据库层专注存储与查询。
收益是可扩展性(Scalability)、可维护性(Maintainability)和安全性(Security)更好:应用层可独立水平扩容(Horizontal Scaling);数据库不直接暴露给客户端;业务逻辑演进也更可控。

22. N 层(N-tier)架构是什么?为什么大型系统更常用它?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: n-tier, client-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de875623565038f409707 | 官方: 是 | 付费: 否

答案:

答案N 层架构是在三层基础上继续拆分更多层,例如缓存层(Cache Layer)、网关层(Gateway Layer)、认证层(Authentication Layer)、日志/监控层(Logging/Monitoring Layer)、搜索层(Search Layer)等,用于承载特定职责。
它的价值在于“可插拔扩展”:不同层可以按需扩容或替换,实现更细粒度的性能优化与安全治理。
大型系统业务复杂、流量波动大,用 N 层可以把热点功能独立伸缩,并降低单点瓶颈与跨团队协作成本。

23. 客户端-服务器架构(Client-Server Architecture)有哪些主要优势?请从运维、扩展、安全角度概括。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: benefits, client-server)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de878623565038f409ae5 | 官方: 是 | 付费: 否

答案:

答案运维上,服务器集中管理资源与配置,更新、监控、故障排查更统一,客户端只需按需升级。
扩展上,服务器可以通过垂直(Vertical Scaling)或水平扩容(Horizontal Scaling)承载更多请求,多客户端共享同一套服务能力与数据资源。
安全上,数据与权限控制集中在服务器侧,便于实施认证(Authentication)、加密(Encryption)、访问控制(Access Control)与审计(Audit),比把关键数据放在客户端更安全。

24. 在现实世界中,哪些应用场景最典型地使用客户端-服务器架构?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, architecture;标签: client-server, architecture)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de87c623565038f409ebd | 官方: 是 | 付费: 否

答案:

答案几乎所有互联网应用都在用客户端-服务器模型:网页浏览时浏览器向 Web 服务器(Web Server)请求 HTML/CSS/图片等资源。
邮件服务中,客户端(如 Outlook/Gmail)连接邮件服务器(Mail Server)完成收发与同步;在线银行由客户端提交交易请求,服务器校验并返回账户信息。
云计算平台则把计算、存储、数据库等资源以服务形式提供给客户端按需调用,本质仍是客户端请求、服务器提供能力的模式。

25. 微服务(Microservices)为什么强调“单一职责原则(SRP)”?落到服务边界上怎么理解?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, ddd;标签: SRP, service boundaries)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de9ab623565038f40d6c3 | 官方: 是 | 付费: 否

答案:

答案SRP 的核心是“把因同一个原因变化的东西聚在一起,把因不同原因变化的东西分开”。落到微服务边界:一个服务最好围绕一个业务能力(如订单、库存、支付)闭环,内部变化由同一团队负责;跨能力的变化通过契约(API/事件)协作。这样可以减少跨团队协调成本,降低耦合,并让服务更容易独立演进。

26. 微服务为什么需要集中式日志(Log Aggregation)?ELK 典型链路是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, observability;标签: logging, ELK)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daba | 官方: 是 | 付费: 否

答案:

答案微服务(Microservices)实例分散且会弹性伸缩(Elastic Scaling),单机查日志很难串联一次请求的全链路。集中式日志(Centralized Logging)把各实例日志统一采集、索引与检索,支持关联分析与告警。ELK(Elasticsearch, Logstash, Kibana)常见链路是:服务输出日志 → 采集/转发(如 Logstash/Beats)→ Elasticsearch 建索引与存储 → Kibana 查询与可视化。

27. 微服务“去中心化”组织方式是什么?为什么强调团队端到端负责?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: microservices, devops;标签: team ownership, decentralization)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696de9b2623565038f40dcb5 | 官方: 是 | 付费: 否

答案:

答案去中心化强调“你写的服务你负责”:团队不仅开发,还要部署、运维、支持与持续改进。好处是反馈闭环更快、质量责任更明确、交付更连续;也推动团队把自动化、文档、可观测性(Observability)做扎实。配合内部开源/贡献模型(他人可提 PR(Pull Request)),能进一步提高协作效率并形成稳定的服务边界。

28. 什么是 Serverless 架构?它为什么不是“没有服务器”?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: serverless, faas, cloud;标签: Basics, FaaS)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f19 | 官方: 是 | 付费: 否

答案:

答案Serverless 是一种由云厂商动态管理计算资源的架构模式(Architecture Pattern),开发者以函数/托管服务的形式部署代码,不需要自行采购、配置和运维服务器。它并不是没有服务器,而是“服务器管理对开发者不可见”:扩缩容、补丁、负载均衡等由云平台负责,团队只关注业务逻辑与事件触发链路(Event Trigger Chain)。

29. Serverless 的计费模式是什么?为什么更适合突发流量或间歇任务?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: serverless, cost-optimization;标签: Billing, Cost)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f26 | 官方: 是 | 付费: 否

答案:

答案Serverless 通常按“执行次数 + 执行时长 + 分配内存/CPU”计费,而不是按预留机器容量计费。没有请求时几乎不产生计算费用,因此对峰谷明显、流量突发、定时任务/事件驱动的工作负载更划算:高峰自动扩容承接请求,低谷自动缩到零,避免闲置成本。

30. 什么是 FaaS(Functions as a Service)?它和传统应用部署的核心差异是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: faas, serverless, event-driven;标签: FaaS, Deployment)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f29 | 官方: 是 | 付费: 否

答案:

答案FaaS(函数即服务)是 Serverless 的典型形态:把业务逻辑拆成可独立部署的小函数,由事件触发执行,执行完成后环境可回收。与传统部署相比,核心差异在于:以事件为中心(HTTP/队列/存储/定时器触发)、函数天然短生命周期与无状态(Stateless)、平台负责扩缩容与运行时管理,应用更多依赖外部服务来存储状态与实现编排(Orchestration)。

31. 列举 3-5 个最常见的 Serverless 使用场景,并说明为什么适合。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: serverless, use-cases;标签: Use Cases, Examples)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dece1623565038f416f89 | 官方: 是 | 付费: 否

答案:

答案常见场景:1)API/后端接口(按请求弹性伸缩);2)异步任务与事件处理(队列/存储事件触发);3)数据处理(图片处理、ETL(Extract, Transform, Load)、小型流处理);4)自动化运维(定时清理、告警自愈);5)工作流编排(多步骤业务流程)。它们共同特点是事件驱动(Event-Driven)、负载波动明显、可拆分为短任务,适合按需计费与自动扩缩容。

32. 什么是事件驱动架构(EDA),它解决了什么问题?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, messaging, microservices;标签: EDA, event bus, decoupling)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188de | 官方: 是 | 付费: 否

答案:

答案事件驱动架构(EDA(Event-Driven Architecture))是一种以“事件”为中心的系统设计方式:系统把业务状态变化(如下单、支付成功、库存变更)表示成事件,发布到事件总线(Event Bus)/消息中间件(Message Broker),由感兴趣的服务异步订阅并做出反应。
它主要解决了分布式系统里“解耦、扩展与实时反应”的问题:生产者不需要知道消费者是谁,新增/替换消费者不会影响生产者,同时天然适配高并发与实时处理。

33. 事件驱动编程(EDP)和事件驱动架构(EDA)有什么区别?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, nodejs, microservices;标签: EDP vs EDA, architecture, programming)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188eb | 官方: 是 | 付费: 否

答案:

答案EDP(事件驱动编程(Event-Driven Programming))是代码层面的编程范式:函数/处理器在事件触发时执行,比如 GUI 点击回调、Node.js 的 event loop(事件循环)。
EDA(Event-Driven Architecture)是系统层面的架构模式:跨服务用事件进行异步协作(pub/sub(Publish/Subscribe)、stream(Stream)),关注通信拓扑、可靠性、事件模型与运维治理。EDP(Event-Driven Processing)常用于实现 EDA 中的消费者/处理器。

34. 什么是点对点(P2P(Peer-to-Peer))网络?它与客户端-服务器架构的核心区别是什么?

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design, networking;标签: P2P, Client-Server, Architecture)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696def25623565038f41c58e | 官方: 是 | 付费: 否

答案:

答案P2P(Peer-to-Peer)是一种去中心化网络架构,参与者(peer(Peer))之间直接共享资源与信息,不依赖单一中心服务器。每个 peer(Peer)既可以作为客户端发起请求,也可以作为服务器提供数据/带宽/算力等资源。与客户端-服务器模型相比,P2P(Peer-to-Peer)的控制与负载分散在大量节点上,减少单点故障,但也带来管理、可信与一致性等复杂度。

35. 如果让你向小朋友解释什么是 API(Application Programming Interface),你会怎么说?

  • 知识点: 后端 / 算法与数据结构 / 行为与软技能 (主题: api, fundamentals;标签: api, communication, basics)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 696f113f120fcc159115927d | 官方: 是 | 付费: 否

答案:

答案API(Application Programming Interface)像点餐的服务员:你(一个应用)把需求告诉服务员(API(Application Programming Interface)),服务员去厨房(另一个系统)拿结果再端回来。API(Application Programming Interface)负责约定“怎么请求/怎么返回”,让不同程序安全、稳定地协作。

36. HTTP(Hypertext Transfer Protocol)中 GET(GET)和 POST(POST)有什么区别?分别适用于哪些场景?

  • 知识点: 后端 / 操作系统与网络 (主题: http;标签: HTTP, REST)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Carsales
  • id: 697042c1120fcc1591302fbe | 官方: 是 | 付费: 否

答案:

答案GET(GET):读取资源;应是安全(safe)且幂等(idempotent);参数通常在 query(Query);可被缓存;URL(Uniform Resource Locator)长度有限。
POST(POST):创建/提交数据;不保证幂等;请求体在 body(Body);常用于创建资源、触发动作、复杂查询提交等。
AnswerGET: retrieve data; safe + idempotent; params in query; cacheable; URL length limits.

答案GET:检索数据;安全且幂等;参数在查询中;可缓存;URL长度有限制。
POST: submit/create; not necessarily idempotent; payload in body; used for creation, actions, or complex requests.
POST:提交/创建;不一定幂等;负载在请求体中;用于创建、操作或复杂请求。

37. 解释什么是 Network(Network)和 Node(Node)。

  • 知识点: 后端 / 操作系统与网络 (主题: networking;标签: Network, Node, Topology)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 697729f6a39c9c5c3a8ab1eb | 官方: 是 | 付费: 否

答案:

答案Network(Network)是由多个设备通过有线/无线介质连接形成的通信集合,用于数据交换与资源共享(如文件、打印机、服务)。Node(Node)是网络中的一个连接点或设备实体,例如电脑、手机、路由器、服务器、IoT(Internet of Things)设备等。节点通过链路与协议进行通信,一个网络包含的节点数量越多,通常对寻址、路由、带宽与安全管理的要求也越高。

38. 什么是 REST(Representational State Transfer)?用示例解释 RESTful Web 服务。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api, rest, web;标签: REST, HTTP Methods, Stateless, JSON)
  • 类型: technical | 难度: easy | 子类型:
  • 分类: fullstack
  • id: 69773804a39c9c5c3a8e1625 | 官方: 是 | 付费: 否

答案:

答案REST(Representational State Transfer)是一种面向资源的架构风格,通过统一接口用 HTTP(Hypertext Transfer Protocol)方法操作资源:GET(GET)查询、POST(POST)创建、PUT/PATCH(PUT/PATCH)更新、DELETE(DELETE)删除;资源用 URI(Uniform Resource Identifier)标识,服务应尽量无状态,常用 JSON(JavaScript Object Notation)表达。示例:/users 表示用户集合,GET /users/123 获取用户,POST /users 创建用户,PUT /users/123 更新用户,DELETE /users/123 删除用户。RESTful 设计强调清晰的资源建模、合理状态码与可缓存性。

39. What exactly is resource mapping?

资源映射到底是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97495 | 官方: 否 | 付费: 否

答案:

Redirects, vanity URLs, and virtual hosts are all defined via resource mapping in AEM. To obscure the internal structure of the AEM site from visitors, utilise resource mapping to prefix all requests with "/content." You can also create a redirect using resource mapping, which will send all requests to your site's doorway page to some other site.

重定向、虚荣URL和虚拟主机都是通过AEM中的资源映射定义的。为了对访问者隐藏AEM站点的内部结构,利用资源映射将所有请求加上"/content"前缀。您还可以使用资源映射创建重定向,将针对您网站入口页的所有请求发送到其他站点。

40. In AEM, what design patterns are used?

在AEM中,使用了哪些设计模式?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97498 | 官方: 否 | 付费: 否

答案:

Many of the OSGI design patterns are relevant to AEM because it is built on OSGi. Design patterns include Singleton (Service), Adapter Service, Resource Adapter Service, and Whiteboard. Because AEM is modular, you should be able to utilise any design pattern in your project.

由于AEM构建在OSGi之上,因此许多OSGi设计模式与AEM都相关。设计模式包括单例(服务)、适配器服务、资源适配器服务和白板。因为AEM是模块化的,您应该能够在项目中利用任何设计模式。

41. What is the distinction between bundle and package?

bundle和package之间的区别是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b9749b | 官方: 否 | 付费: 否

答案:

  • A bundle is a collection of tightly coupled, dynamically loadable classes, jars, and configuration files that specifically indicate their external dependencies (if any). A Java archive file containing Java code, resources, and a manifest that identifies the bundle and its dependencies is known as an OSGi bundle. A bundle is the smallest unit of modularization. Along with out-of-the-box bundles, we can easily install our own custom bundles in AEM.
  • A Package is a zip file that contains content in the form of a file-system serialisation (also termed as "vault" serialisation) that displays content from the repository as a simple-to-use-and- modify the representation of the filesystem. Packages can contain content as well as project-related information.

42. Distinguish between parsys and iparsys.

区分parsys和iparsys。
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b9749e | 官方: 否 | 付费: 否

答案:

  • parsys: It's known as the "Paragraph System" component, and it allows you to add other components to a page.
  • iparsys: It's an inherited paragraph system that takes after the "paragraph system" of the parent page.

43. What is Sling in AEM?

AEM中的Sling是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974a1 | 官方: 否 | 付费: 否

答案:

In AEM, Sling is used to create web applications. Web applications that are mostly content-oriented can be developed using the framework. It is built on top of the JCR and is based on REST concepts (Java Content Repository). It's used to store and manage the Java Repository's content.

在AEM中,Sling用于创建Web应用程序。可以使用该框架开发主要是面向内容的Web应用程序。它构建在JCR之上,并基于REST概念(Java内容仓库)。它用于存储和管理Java仓库的内容。

44. What is the definition of a replication agent?

复制代理的定义是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974a4 | 官方: 否 | 付费: 否

答案:

Replication agents are central to AEM. These are the mechanisms used by Adobe Experience Manager (AEM) to: - Activate (publish) content from an author to a publish environment.

复制代理是AEM的核心。这些是Adobe Experience Manager (AEM) 用于以下目的的机制:- 将内容从创作环境激活(发布)到发布环境。
  • Flush content from the Dispatcher cache deliberately.
  • Deliver user input from the publish environment to the author environment (for example, form input) (under control of the author environment).

45. In AEM, what is a workflow and a workflow model?

在AEM中,什么是工作流和工作流模型?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974a7 | 官方: 否 | 付费: 否

答案:

The workflow feature in AEM allows users to automate tasks in the CMS (Content Management System) instance. A workflow is a well-defined series of actions that include participants, a process, and possibly certain tools. When many procedures can execute simultaneously, they might be either sequential or parallel. In AEM, a workflow is similar to a flowchart in that it outlines a series of procedures that must be completed by various participants in order to produce the desired result.

AEM中的工作流功能允许用户在CMS(内容管理系统)实例中自动化任务。工作流是一系列明确定义的操作,包括参与者、流程以及可能某些工具。当许多程序可以同时执行时,它们可能是顺序的或并行的。在AEM中,工作流类似于流程图,它概述了必须由不同参与者完成的一系列程序步骤,以产生预期结果。

A workflow model is a container or template for the workflow that logically connects the workflow steps. - By default, it has a start and an end node (along with an optional participant step).

工作流模型是工作流的容器或模板,逻辑上连接工作流步骤。- 默认情况下,它有开始节点和结束节点(以及一个可选的参与者步骤)。
  • It can contain a variety of nodes as well as the transitions that connect them. The workflow nodes can receive any type of input from the author and process it using Java code or ECMA scripts.
  • Workflow payload is a term that refers to a resource that the workflow will use to carry out its tasks.

46. Explain the difference between CQ5.4 and CQ5.5.

解释CQ5.4和CQ5.5之间的区别。
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974aa | 官方: 否 | 付费: 否

答案:

Before version 5.5, CQ was built on a servlet container (CQSE by default, but others may be used) that ran multiple web applications: one for the CRX content repository and another for the OSGi container, which contained Sling and AEM. The majority of the request processing was handled by the Sling web app, which was connected to the root. The following are some points to remember for CQ5.5: - The OSGi container is at the root of CQ 5.5 and AEM, with the OSGi HTTP service, supported by Sling, acting as the only request handling endpoint.

在5.5版本之前,CQ构建在servlet容器(默认为CQSE,但也可以使用其他容器)上,该容器运行多个Web应用程序:一个用于CRX内容存储库,另一个用于包含Sling和AEM的OSGi容器。大多数请求处理由连接到根路径的Sling Web应用程序处理。以下是一些需要记住的CQ5.5要点:- OSGi容器位于CQ 5.5和AEM的根路径,由Sling支持的OSGi HTTP服务作为唯一的请求处理端点。
  • Along with the many services that make up the rest of the AEM functionality, the CRX content repository is now just another OSGi service. These modifications have no impact on AEM or Sling-based apps.
  • Because of the new design, AEM's quickstart jar installation can no longer enable the use of other web applications alongside AEM.
  • The war version of AEM, on the other hand, is designed to be installed in an application server alongside other web applications.
  • Three new connectors for Adobe products – Creative Suite, Scene7, and Search&Promote – have been added.
  • The authors will be able to work directly on mobile applications.
  • Hybrid software was partnered with to give some wonderful eCommerce functionality.
  • Undo(Ctrl+z) and Redo(Ctrl+y) functions have been added.

47. What is AEM Testing?

什么是AEM测试?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974ad | 官方: 否 | 付费: 否

答案:

For automated tests for your AEM UI, AEM provides the Bobcat testing framework. This framework, which provides a Javascript API for generating tests, allows you to write and run UI tests directly in a web browser. It also makes use of Hobbes.js, a Javascript-based testing package. The Hobbes.js framework was created as part of the development process for testing AEM and is now available for public usage for testing your AEM apps. It's an open-source test automation framework for web application functional testing.

对于AEM UI的自动化测试,AEM提供了Bobcat测试框架。该框架提供了用于生成测试的JavaScript API,允许您直接在Web浏览器中编写和运行UI测试。它还使用了Hobbes.js,一个基于JavaScript的测试包。Hobbes.js框架是在测试AEM的开发过程中创建的,现在可供公开使用来测试您的AEM应用程序。它是一个用于Web应用程序功能测试的开源测试自动化框架。

48. What is AEM Explorer?

什么是AEM Explorer?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974b0 | 官方: 否 | 付费: 否

答案:

AEM Explorer is an acronym for Application Explorer Missions, which is developed for readers with low eyesight, physical limitations, learning and attentional impairments who might benefit from larger, spoken, highlighted, or re-formatted text. It makes no mention of Braille, and the Explorer presumes that the guide who is using the program has a vision.

AEM Explorer是Application Explorer Missions的缩写,专为视力低下、身体受限、学习和注意力障碍的读者开发,他们可能从更大、语音朗读、高亮或重新格式化的文本中受益。它没有提及盲文,并且Explorer假定使用该程序的向导具备视力。

49. In AEM, what is a component?

在AEM中,什么是组件?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974b3 | 官方: 否 | 付费: 否

答案:

In AEM, components are reusable modules that execute specific application logic to generate our website's content. The material available on your web pages is held, formatted, and rendered using AEM components. The components allow authors to change and configure content while creating pages. A JSP (Java Server Pages) or HTML file is frequently included in a component. HTML files provide the component's HTML markup as well as some business logic. A typical AEM page is made up of a lot of different elements. To put it another way, Components are the basic building blocks of AEM pages.

在AEM中,组件是可重用的模块,执行特定的应用程序逻辑以生成我们网站的内容。您的网页上可用的材料使用AEM组件来保存、格式化和渲染。组件允许作者在创建页面时更改和配置内容。JSP(Java Server Pages)或HTML文件通常包含在组件中。HTML文件提供组件的HTML标记以及一些业务逻辑。一个典型的AEM页面由许多不同的元素组成。换句话说,组件是AEM页面的基本构建块。

50. In AEM, what is a template?

在AEM中,什么是模板?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974b6 | 官方: 否 | 付费: 否

答案:

A Template helps you to set a uniform style for your application's pages. It also specifies which components (reusable modules) are permitted to be used within the scope chosen. It's a tree of nodes with the same structure as the page you're going to make. It is devoid of any actual content. AEM offers static as well as editable templates. Templates are used in AEM at several points: - When building a new page, you would first choose a template that will serve as the foundation for the new page. The template specifies the structure of the final page, as well as any starting content and possible components (design properties).

模板帮助您为应用程序的页面设置统一的样式。它还指定了在所选范围内允许使用哪些组件(可重用模块)。它是一个节点树,结构与您要创建的页面相同。它不包含任何实际内容。AEM提供静态模板和可编辑模板。模板在AEM中用于多个方面:- 构建新页面时,您首先会选择模板作为新页面的基础。该模板指定最终页面的结构,以及任何初始内容和可能的组件(设计属性)。
  • You would also choose a template when generating a Content Fragment. The structure, basic elements, and variants are all defined in this template.

51. What are AEM Connectors?

什么是AEM连接器?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974b9 | 官方: 否 | 付费: 否

答案:

The AEM Connector works with a wide range of search systems, from open-source like Elasticsearch and Solr to commercial solutions like Azure Search, SharePoint Search, Endeca, and others, similar to our search engine independent connectors. The AEM connector allows businesses to scan and publish their websites and digital assets from within an AEM server to their existing search engines. This allows all search tasks to be completed within the search engine, minimising the AEM server's processing burden and offering a variety of search capabilities, from basic to advanced.

AEM连接器适用于广泛的搜索系统,从开源系统如Elasticsearch和Solr到商业解决方案如Azure Search、SharePoint Search、Endeca等,类似于我们与搜索引擎无关的连接器。AEM连接器允许企业从其AEM服务器内部扫描和发布其网站和数字资产到其现有的搜索引擎。这允许所有搜索任务在搜索引擎内完成,最小化AEM服务器的处理负载,并提供从基础到高级的各种搜索功能。

It has throttling tools and procedures to control the number of requests made in a given time period, allowing the connector to send many queries to the AEM server without affecting its performance or availability. It allows exclusive individuals and groups to securely view the documents meant for them.

它具有节流工具和流程,用于控制给定时间段内发出的请求数量,使连接器能够向AEM服务器发送大量查询,而不会影响其性能或可用性。它允许特定的个人和组安全地查看为他们准备的文档。

52. What is the definition of a content repository? What exactly is JCR (Java Content Repository)?

内容仓库的定义是什么?什么是JCR(Java内容仓库)?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974bc | 官方: 否 | 付费: 否

答案:

A content repository is essentially a storage location for digital content. The content repository's structure is often hierarchical and represented as a tree structure, with each node of the tree serving as a storage location for content.

内容仓库本质上是数字内容的存储位置。内容仓库的结构通常是分层的,并以树状结构表示,树中的每个节点都作为内容的存储位置。

Java Content Repository is a Java community specification for accessing content repositories in a consistent manner (platform-independent and vendor-independent way). JSR-170(JCR 1.0) was the first version of the specification, and version 2 was released subsequently (JCR-283). The javax.JCR API gives access to a content repository through multiple classes and interfaces.

Java内容仓库是一个Java社区规范,用于以一致的方式(独立于平台和供应商的方式)访问内容仓库。JSR-170(JCR 1.0)是该规范的第一个版本,随后发布了版本2(JCR-283)。javax.JCR API通过多个类和接口提供对内容仓库的访问。

53. What is the foundation of CQ5's technology stack?

CQ5技术栈的基础是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974bf | 官方: 否 | 付费: 否

答案:

Three technologies make up the CQ5 technological stack. Apache Sling, OSGi (Apache Felix), and the Java Content Repository (JCR) are the technologies in the discussion. Apache Sling is a RESTful framework for interacting with a JCR via the HTTP protocol. The request URL will then be mapped to the JCR node. OSGi is a Java framework that allows for the construction of modular applications. During runtime, each module, referred to as a bundle, can be stopped and started individually. The JSR-170 API is used by the Java Content Repository to access the content repository using Java, regardless of the physical implementation. CQ5 uses CRX, which is its own JCR implementation.

三种技术构成了CQ5技术栈。讨论中的技术是Apache Sling、OSGi(Apache Felix)和Java内容仓库(JCR)。Apache Sling是一个RESTful框架,用于通过HTTP协议与JCR交互。请求URL随后会被映射到JCR节点。OSGi是一个Java框架,允许构建模块化应用程序。在运行时,每个模块(称为bundle)可以单独停止和启动。Java内容仓库使用JSR-170 API,通过Java访问内容仓库,而与物理实现无关。CQ5使用CRX,这是它自己的JCR实现。

54. What is sightly in AEM?

AEM中的Sightly是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974c2 | 官方: 否 | 付费: 否

答案:

In AEM 6.0, Sightly was introduced as an HTML templating language. It is intended to replace JSP files and is the primary HTML templating solution. The word "sightly" implies "pleasant to the eye," and its goal is to make your markup look nice and tidy. The following benefits of using Sightly: - Lightweight — There are no dependencies, thus it is quick and lean.

在AEM 6.0中,Sightly被引入作为一种HTML模板语言。它旨在替代JSP文件,并成为主要的HTML模板解决方案。“Sightly”一词意为“赏心悦目”,其目标是让你的标记看起来美观整洁。使用Sightly的以下好处:- 轻量级——没有依赖项,因此快速且精简。
  • Secure - Contextual XSS (Cross-site scripting) prevention and URL externalisation are both automatic.
  • Powerful – A simple logic API that allows you to perform almost anything.
  • Intuitive - A feature set that is clear, basic, and limited.

55. What is the need for a Content Management System (CMS)?

内容管理系统(CMS)的需求是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974c5 | 官方: 否 | 付费: 否

答案:

A content management system (CMS) is a chunk of software for creating and managing files and Web sites. Since a lot of websites and web applications are dynamic, their content must be updated on a regular basis. It is advised that you use a content management system to effectively handle these modifications. Adobe Content Management System is one of the numerous CMS suppliers accessible.

内容管理系统(CMS)是一块用于创建和管理文件及网站的软件。由于许多网站和Web应用程序是动态的,其内容必须定期更新。建议使用内容管理系统来有效处理这些修改。Adobe内容管理系统是可用的众多CMS供应商之一。

56. Why is AEM preferable over other Content Management Systems (CMS)? What level of control does AEM provide you with?

为什么AEM比其他内容管理系统(CMS)更受青睐?AEM为你提供了何种程度的控制?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974c8 | 官方: 否 | 付费: 否

答案:

The capacity to build custom digital experiences that are customised to the particular user is AEM's major benefit. AEM lets customers manage digital content efficiently by providing best-in-class features such as content workflows, digital asset management, social, and multi-channel collaboration. AEM is an amazing solution for managing mobile applications, mobile websites, eCommerce, and marketing campaigns, in addition to simple website management. AEM provides a road ahead for digital marketing when combined with other Adobe Marketing Cloud tools.

构建适合特定用户的定制数字体验的能力是AEM的主要优势。AEM通过提供一流的功能(如内容工作流、数字资产管理、社交和多渠道协作)让客户高效管理数字内容。除了简单的网站管理外,AEM还是管理移动应用程序、移动网站、电子商务和营销活动的出色解决方案。与其他Adobe营销云工具结合使用时,AEM为数字营销提供了前进之路。

Without having to work on numerous sets of assets, AEM allows you to create unlimited customizable variations of your website, including the format, distribution method, styles, and more. By connecting with Adobe Creative Cloud to develop and modify assets, AEM makes it simple to connect your creative and marketing workflows. With straightforward content authoring, AEM enables your team to design, build, and manage interactive and responsive digital experiences. An easy-to-use interface can be used to handle images, videos, content, and any other content components. Adobe Analytics data can help you create tailored and targeted experiences. Examine your customers' habits and make the required changes to your website to boost engagement and income.

无需处理多组资产,AEM允许你创建网站的无限可定制变体,包括格式、分发方法、样式等。通过与Adobe Creative Cloud连接来开发和修改资产,AEM使你的创意和营销工作流易于连接。凭借直观的内容创作,AEM让你的团队能够设计、构建和管理交互式且响应式的数字体验。可以使用易于使用的界面来处理图像、视频、内容和任何其他内容组件。Adobe Analytics数据可以帮助你创建量身定制的定向体验。检查客户习惯,并对你的网站进行必要更改,以提高参与度和收入。

57. What is RESTful?

什么是RESTful?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974cb | 官方: 否 | 付费: 否

答案:

REST (Representational State Transfer) is an architectural style and communication strategy that is frequently utilised in the creation of web services. It uses a client-server communications protocol that is stateless and cacheable. HTTP requests are used by RESTful apps to post, read, and wipe out data. Uniform interface, stateless, cacheable, client-server, layered system, and code on demand are the six architectural constraints of REST.

REST(表述性状态转移)是一种架构风格和通信策略,经常用于Web服务的创建。它使用无状态且可缓存的客户端-服务器通信协议。RESTful应用程序使用HTTP请求来发布、读取和删除数据。统一接口、无状态、可缓存、客户端-服务器、分层系统和按需代码是REST的六个架构约束。

58. What are the advantages of utilising OSGi (Open Service Gateway Initiative)?

使用OSGi(开放服务网关倡议)的优势是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974ce | 官方: 否 | 付费: 否

答案:

OSGi (Open Service Gateway Initiative) is a Java platform for creating and deploying modular software. The following are the key advantages of utilising OSGI: - Applications are more adaptive to changing requirements, more portable, and easier to re-engineer.

OSGi(开放服务网关倡议)是一个用于创建和部署模块化软件的Java平台。以下是利用OSGI的主要优势:- 应用程序更能适应需求变化,更具可移植性,且更容易重新设计。
  • The framework delivers the Spring Framework's declarative assembly and simplified unit testing in a standardised version that is given as part of the application server runtime rather than as a third-party library installed as part of the application.
  • The framework is compatible with the Java EE programming model, allowing you to deploy a web application as a collection of versioned OSGi bundles with a dynamic lifespan.
  • It simplifies and standardizes third-party library integration by allowing administrators to manage application bundle dependencies and versions.
  • Enterprise applications made out of several, versioned bundles with dynamic lifecycles benefit from the framework's separation.
  • It comes with a built-in bundle repository that can store common and versioned bundles that are shared among several applications, preventing each application from deploying its own copy of each common library.
  • External bundle repositories are accessible to OSGi apps.
  • At the module level, the framework encourages service-oriented design.
  • It makes the components straightforward to handle since the components can be added, deleted, updated, launched, and terminated at run time.
  • It improves the system's performance because components of the application that aren't in use don't have to be loaded into memory.

59. Explain the life cycle of OSGI bundle.

解释OSGI捆绑包的生命周期。
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974d1 | 官方: 否 | 付费: 否

答案:

Bundles that can be dynamically installed, started, paused, updated, and deleted are added by the OSGi Life-Cycle layer. The security architecture protects all aspects of the life cycle.

OSGi生命周期层添加了可动态安装、启动、暂停、更新和删除的捆绑包。安全架构保护生命周期的所有方面。

The OSGi lifecycle can be broken down into the following steps:

OSGi生命周期可以分为以下步骤:
  • INSTALLED- The bundle has been installed in the OSGi container, but some of its dependencies have still to be satisfied. The bundle requires packages that haven't been exported by any of the other bundles that are presently installed.
  • RESOLVED- The bundle has been installed, and the OSGi system has connected and resolved all of the dependencies at the class level. The bundle is now ready to use. When a bundle is started, it skips this state if all of the bundle's dependencies are met.
  • STARTING -It is the temporary state in which the bundle exists while it is being loaded after all dependencies have been resolved. The BundleActivator.start method will be invoked, but it hasn't returned yet.
  • ACTIVE - The bundle is active, however, it is disabled while Spring is working. Spring examines the Spring setup and creates the context before passing it on to the plugin. In order to make instances of each plugin module, the plugin requires context.
  • STOPPING - It is a brief state in which the bundle is in when it is stopping. Although the BundleActivator.stop function has been called, it has yet to return.
  • UNINSTALLED - The bundle has been removed from the OSGi container.

60. In AEM, what are client libraries?

在AEM中,什么是客户端库?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974d4 | 官方: 否 | 付费: 否

答案:

Client-side processing, aided by advanced JavaScript and CSS code, is used widely on modern websites. Organizing and improving the code's servicing can be a difficult task.

借助高级JavaScript和CSS代码的客户端处理,在现代网站上被广泛使用。组织和改进代码的服务可能是一项困难的任务。

AEM includes Client-side Library Folders to help with this problem. These folders allow you to store client-side code in the repository, organise it into categories, and determine when and how each category of code is given to the client. The client-side library system then creates the appropriate links in your final webpage to load the appropriate code. The AEM client library is responsible for managing all Javascript, client-side code, and CSS resources such as pictures and fonts. It aids in resource and code maintenance, debugging, merging, and minimization.

AEM包含客户端库文件夹以帮助解决此问题。这些文件夹允许您将客户端代码存储在存储库中,将其组织到类别中,并确定每类代码何时以及如何提供给客户端。然后,客户端库系统在最终网页中创建适当的链接以加载适当的代码。AEM客户端库负责管理所有Javascript、客户端代码和CSS资源,如图片和字体。它有助于资源和代码的维护、调试、合并和最小化。

61. What's the best way to get digital assets loaded into the DAM (Digital Asset Management)?

将数字资产加载到DAM(数字资产管理)的最佳方式是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974d7 | 官方: 否 | 付费: 否

答案:

One can add digital assets to the DAM by using the graphical user interface or WebDav (Web Distributed Authoring and Versioning) access. If you're using the graphical user interface, all you have to do is browse for the files you want to add, and CQ will build metadata for them in the DAM folder. When you need to upload a big number of assets at once, you'll most likely use WebDav which is essentially a set of extensions to the Hypertext Transfer Protocol (HTTP) that allow user agents to collaboratively write contents straightforwardly in an HTTP web server by offering concurrency control and namespace operations, letting the Web to be seen as as an editable, collaborative medium rather than a read-only medium.

可以通过使用图形用户界面或WebDav(Web分布式创作和版本控制)访问向DAM添加数字资产。如果您使用图形用户界面,只需浏览要添加的文件,CQ将在DAM文件夹中为它们构建元数据。当您需要一次上传大量资产时,您最可能使用WebDav,它本质上是超文本传输协议(HTTP)的一组扩展,允许用户代理通过提供并发控制和命名空间操作直接在HTTP Web服务器上协作编写内容,使Web被视为可编辑的协作媒介,而不是只读媒介。

62. What do you understand about a CQ5 overlay/override component?

你对CQ5覆盖/重写组件有何理解?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974da | 官方: 否 | 付费: 否

答案:

When you wish to work with an out-of-the-box component (Each out-of-the-box component is a set of scripts that completely perform a particular task in order to achieve the desired functionality) in AEM as well as wish to incorporate more functionality to it and change it overall instances of that component, you use the overlay/override component. If you want to incorporate functionality to the out-of-the-box "text" component but don't want to develop a new one, you can copy the "text" component to "apps/foundation/components" from "libs/foundation/components" while maintaining the same folder structure. Any modifications made to this new component will be mirrored in the out-of-the-box "text" component, without requiring any changes to the existing code under "libs". Modifying the original code is often not a smart idea, therefore, CQ allows you to utilise overlays.

当您希望在AEM中使用开箱即用组件(每个开箱即用组件是一组脚本,它们完全执行特定任务以实现所需功能),并且希望向其添加更多功能并更改该组件的所有实例时,您可以使用覆盖/重写组件。如果您想为开箱即用的“文本”组件添加功能但不想开发新组件,您可以将“文本”组件从“libs/foundation/components”复制到“apps/foundation/components”,同时保持相同的文件夹结构。对此新组件所做的任何修改都将反映在开箱即用的“文本”组件中,无需更改“libs”下的现有代码。修改原始代码通常不是一个好主意,因此CQ允许您使用覆盖。

63. What's the distinction between a dialog and a design dialog?

对话框和设计对话框有什么区别?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974dd | 官方: 否 | 付费: 否

答案:

Dialogs & Design Dialogs are the group of widgets employed to obtain input from the author. These are the most important parts of a component since they allow the author to communicate with the CQ5 component. It indicates that values entered by the author in these dialogs are used as input for a CQ5 component.

对话框和设计对话框是用于从作者处获取输入的一组小部件。它们是组件最重要的部分,因为它们允许作者与CQ5组件进行通信。这表明作者在这些对话框中输入的值被用作CQ5组件的输入。
Criteria
标准
Dialog
对话框
Design Dialog
设计对话框
Definition
定义
Dialog modifies the content at the page level.
对话框在页面级别修改内容。
Design dialog modifies the content at the template level.
设计对话框在模板级别修改内容。
Availability
可用性
authored in edit mode
在编辑模式下创作
authored in design mode
在设计模式下创作
Value Storage
值存储
stored under the pages jcr:content node
存储在页面的jcr:content节点下
stored under the design page located under /etc/design
存储在位于/etc/design下的设计页面下
Accessing Values in CQ5 JSPs
在CQ5 JSP中访问值
through properties object
通过properties对象
through currentStyle object.
通过currentStyle对象。

64. What are xtypes and how can they help you in AEM?

什么是xtypes,它们如何在AEM中帮助您?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974e0 | 官方: 否 | 付费: 否

答案:

An xtype is a metaphorical name for a class in the ExtJS language. These xtypes are widgets in AEM that are used to create components. AEM offers a number of widgets that are ready to use right now. You may also utilise AEM to develop and define your custom xtype. When establishing a dialog for your component, for example, if you want that the author should be able to provide/enter text, you would add a “cq:Widget” with the xtype property of “textfield.”

xtype是ExtJS语言中类的隐喻名称。在AEM中,这些xtype是用于创建组件的小部件。AEM提供了许多立即可用的小部件。您也可以利用AEM来开发和定义自己的自定义xtype。例如,在为组件建立对话框时,如果您希望作者能够提供/输入文本,您将添加一个xtype属性为“textfield”的“cq:Widget”。

65. What are the basic SCR Annotations for OSGI component creation?

创建 OSGi 组件的基本 SCR 注解有哪些?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974e3 | 官方: 否 | 付费: 否

答案:

The following are the basic SCR annotations for constructing an OSGi component or service:

以下是构建 OSGi 组件或服务的基本 SCR 注解:

@Component — this attribute indicates that the class is a component.

@Component — 此属性表示该类是一个组件。

@Service – specifies the service interface that the component provides.

@Service — 指定组件提供的服务接口。

@Reference — injects a reference to service into a component.

@Reference — 将服务引用注入到组件中。

@Property — defines a class property.

@Property — 定义类属性。

66. What is the distinction between the Author environment and the Publish environment?

作者环境和发布环境之间有什么区别?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974e6 | 官方: 否 | 付费: 否

答案:

AEM is normally running in two different instances in a production environment. The author instance is one, and the publish instance is another. These two instances are typically kept in separate locations. You'll enter and administer content for your website in the author instance. This is also where you are going to manage your website. Typically, the author's environment is kept behind a firewall. You'll make your content available to your selected audience in the publish instance. In most cases, the publishing environment is preserved in a Demilitarized Zone (DMZ).

AEM 在生产环境中通常运行在两个不同的实例上。一个是作者实例,另一个是发布实例。这两个实例通常位于不同的位置。你将在作者实例中输入和管理网站内容,这也是你管理网站的地方。通常,作者环境位于防火墙之后。你将在发布实例中将内容提供给选定的受众。在大多数情况下,发布环境保存在隔离区(DMZ)中。

AEM Questions for Experienced

67. What is AEM Brackets Extension?

什么是 AEM Brackets 扩展?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974e9 | 官方: 否 | 付费: 否

答案:

The AEM Brackets Extension streamlines the editing of AEM components and client libraries by leveraging the Brackets code editor's ability to access Photoshop files and layers from within the code editor. The extension's simple synchronisation (no Maven or File Vault required) boosts development efficiency while also allowing front-end developers with limited AEM experience to participate in projects. This extension also includes partial support for the HTML Template Language (HTL), which simplifies and secures component creation by removing the complexity of JSP.

AEM Brackets 扩展通过利用 Brackets 代码编辑器从代码编辑器内访问 Photoshop 文件和图层的能力,简化了 AEM 组件和客户端库的编辑。该扩展的简单同步(无需 Maven 或 File Vault)提高了开发效率,同时允许 AEM 经验有限的前端开发人员参与项目。此扩展还部分支持 HTML 模板语言(HTL),通过消除 JSP 的复杂性来简化和保护组件创建。

68. What is reverse replication, and how does it work?

什么是反向复制,它是如何工作的?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974ec | 官方: 否 | 付费: 否

答案:

The process of copying content from the publish environment to the author environment is known as reverse replication. You'll need a reverse replication agent on your author instance that's enabled to get content from the publish environment outbox to achieve this.

将内容从发布环境复制到作者环境的过程称为反向复制。你需要在作者实例上配置一个反向复制代理,该代理已启用从发布环境出站框获取内容,以实现此目的。

Publish instance is used in reverse replication. User data is stored in the "outbox" by the reverse replication agent (A repository location where data is temporarily held). Another agent matching agent exists in the author instance, and it polls data from publish on a regular basis. If data is found in the publish instance's outbox, it is synchronised with the author instance. This way, data synchronisation from publisher to author can be managed.

发布实例用于反向复制。用户数据由反向复制代理存储在“出站框”中(仓库中数据临时存放的位置)。作者实例中存在匹配的代理,它会定期轮询发布实例中的数据。如果在发布实例的出站框中找到数据,则会与作者实例同步。这样,可以管理从发布者到作者的数据同步。

69. What exactly is the distinction between par base and parsys?

par base 和 parsys 之间的确切区别是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974ef | 官方: 否 | 付费: 否

答案:

  • par base: Similar to subclasses in object-oriented languages like Java, C++, and others, the par base allows components to inherit properties from other components. When you open the CRX Explorer and look at the /libs/foundation/components/text node, you'll notice that it includes a property entitled sling:resourceSuperType, which refers to the par base component. The par base defines tree scripts to render pictures, titles, and other elements, which can be used by all components subclassed from this par base.
  • parsys: The paragraph system (parsys) is a compound component that enables authors to add various types of components to a page while also including all other paragraph components. Every form of the paragraph is represented by a component. The paragraph system is a component in and of itself, as are the other paragraph components.

70. What is the purpose of the Multi-Site Manager?

Multi-Site Manager 的用途是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974f2 | 官方: 否 | 付费: 否

答案:

MSM (Multi-Site Manager) makes it simple to administer many websites that share content. MSM allows you to build site relationships so that content updates on one site are automatically reproduced on others.

MSM(Multi-Site Manager)使管理共享内容的多个网站变得简单。MSM 允许你建立站点关系,以便一个站点上的内容更新自动复制到其他站点。

For foreign audiences, websites, for example, are frequently supplied in different languages. A manual approach for synchronising content across sites is viable when the number of sites in the same language is small (three to five). However, as the number of sites expands or when many languages are involved, automating the process becomes more efficient.

对于外国受众,例如网站,通常会提供不同语言的版本。当同语言网站数量较少(三到五个)时,手动同步跨站点内容的方法是可行的。然而,随着网站数量增加或涉及多种语言时,自动化该流程会变得更高效。

71. What do you understand about extending a component?

你对扩展组件有何理解?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974f5 | 官方: 否 | 付费: 否

答案:

Extending a component occurs when you want to construct a new component that does not override a base component but has the same characteristics as the original so that you may build upon it. When extending a component, you must set the component's "sling: resourceSuperType" to the base component you want to keep.

扩展组件发生在你想构建一个新组件,该组件不覆盖基础组件但具有与原组件相同的特性,以便你可以在其基础上进行构建时。扩展组件时,你必须将组件的“sling: resourceSuperType”设置为你想要保留的基础组件。

72. In AEM, what is the listener property?

在AEM中,监听器属性是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974f8 | 官方: 否 | 付费: 否

答案:

In AEM, the listener attribute for a component is used to define what happens before or after a component activity. This is done by using the "cq:listeners" node with the "cq:EditListenersConfig" node type. Any widget in AEM can have a listener property attached to it. To add a listener to that widget, simply add a node called "listeners" of the type "nt:unstructured" to the widget. Then all you have to do is add the widget's events as child nodes to the "listeners" node. In the CQ Widget API documentation, you can discover a list of events for each widget.

在AEM中,组件的监听器属性用于定义组件活动之前或之后发生什么。这是通过使用“cq:listeners”节点(类型为“cq:EditListenersConfig”)来完成的。AEM中的任何小部件都可以附加监听器属性。要为此小部件添加监听器,只需向小部件添加一个类型为“nt:unstructured”的名为“listeners”的节点。然后你所要做的就是将小部件的事件作为子节点添加到“listeners”节点。在CQ Widget API文档中,你可以找到每个小部件的事件列表。

73. What is AEM's FileVault Tool (VLT)?

什么是AEM的FileVault工具(VLT)?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974fb | 官方: 否 | 付费: 否

答案:

VLT stands for the Jackrabbit FileVault tool. The Apache Foundation created a utility that transfers the content of a Jackrabbit/AEM instance to your file system. It performs comparable functions to a Subversion (SVN) client, which is a source control system client. It includes standard check-in, check-out, and management features, as well as configuration choices for displaying project content in a variety of ways. The vault sync service is often used to synchronise repository content with a local file system representation, as well as the other way around. Installing an OSGi service that monitors repository updates and analyses the filesystem contents on a regular basis does this. For mapping repository contents to disc, it employs the same serialisation format as a vault. It's worth noting that the service can only sync with the local filesystem and isn't suitable for remote development.

VLT代表Jackrabbit FileVault工具。Apache基金会创建了一个实用程序,用于将Jackrabbit/AEM实例的内容传输到你的文件系统。它执行与Subversion(SVN)客户端(一种源代码控制系统客户端)类似的功能。它包括标准的检入、检出和管理功能,以及以各种方式显示项目内容的配置选项。vault同步服务通常用于将存储库内容与本地文件系统表示同步,反之亦然。这是通过安装一个OSGi服务来实现的,该服务监控存储库更新并定期分析文件系统内容。为了将存储库内容映射到磁盘,它使用与vault相同的序列化格式。值得注意的是,该服务只能与本地文件系统同步,不适合远程开发。

74. What exactly are DAM Renditions?

DAM演绎版到底是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b974fe | 官方: 否 | 付费: 否

答案:

You can use the DAM to produce image renditions that comprise many sizes and versions of the same content. You can incorporate those renditions into your website's content, which is useful when creating thumbnails or smaller views of enormous, high-resolution photographs. This capability is even more crucial when designing multi-device websites when Internet speed is a variable issue. After all, you want any files a site visitor must download to view your site to be as small as possible. Improve your search engine performance and user experience by making your site load faster.

你可以使用DAM生成包含同一内容的多种尺寸和版本的图像演绎版。你可以将这些演绎版整合到网站内容中,这在创建缩略图或大型高分辨率照片的较小视图时非常有用。在设计多设备网站且互联网速度是可变的因素时,此功能甚至更为重要。毕竟,你希望访客必须下载以查看你网站的任何文件尽可能小。通过使网站加载更快来提高搜索引擎性能和用户体验。

75. In CQ5, what is clustering?

在CQ5中,什么是集群?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97501 | 官方: 否 | 付费: 否

答案:

Clustering is a feature that allows two or more AEM instances to share the same repository view, whether they are running on the same machine or on different machines. All cluster instances should, in theory, have the same content, and requests to any node in the cluster should yield the same result. Even when operating a single instance, CQ5 CRX is pre-loaded to run in a cluster. As a result, CQ5 facilitates the deployment of multi-node clusters with minimal effort.

集群是一种功能,允许两个或更多AEM实例共享相同的存储库视图,无论它们运行在同一台机器还是不同机器上。理论上,所有集群实例应具有相同内容,对集群中任何节点的请求应产生相同结果。即使运行单个实例,CQ5 CRX也预加载为以集群模式运行。因此,CQ5以最少的工作量促进了多节点集群的部署。

Clustering in CQ has the following advantages: - High Availability - Clustering helps to ensure high availability in the event of a server or repository failure.

CQ中集群具有以下优势:- 高可用性 - 集群有助于在服务器或存储库故障时确保高可用性。
  • Improve Performance - To improve performance, the load can be balanced between cluster nodes.
  • Backup - If one of the nodes is serving as a passive node, real-time backup is feasible through clustering.

Every repository (or instance) in CQ is referred to as a node. In a Cluster, there is always one master, and the other nodes are referred to as slaves. TCP/IP is used to communicate between the slave and the master. If one of the instances fails, another node takes over as master and the cluster continues to function.

CQ中的每个存储库(或实例)被称为节点。在集群中,始终有一个主节点,其他节点被称为从节点。使用TCP/IP进行从节点和主节点之间的通信。如果其中一个实例失败,另一个节点接管作为主节点,集群继续正常运行。

76. What role does the Servlet Engine play in CQ5?

Servlet引擎在CQ5中扮演什么角色?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97504 | 官方: 否 | 付费: 否

答案:

Servlet Engine acts as a server for each CQ (and CRX, if applicable) instance. Even though CQ WCM can be launched without an application server, a Servlet Engine is always required. Servlets exist in the Application Server and are controlled by the servlet engine. All servlet meta functions are handled by the servlet engine, which is an internal object. Instantiation, initialization, deletion, access from other components, and configuration management are among these functions.

Servlet引擎充当每个CQ(以及CRX,如果适用)实例的服务器。即使CQ WCM可以在没有应用服务器的情况下启动,但始终需要Servlet引擎。Servlet存在于应用服务器中,并由servlet引擎控制。所有servlet元功能由servlet引擎处理,它作为一个内部对象。这些功能包括实例化、初始化、删除、从其他组件访问以及配置管理。

The servlet engine invokes the servlet's init() method to execute any necessary initialization after the servlet is instantiated. You can override this method to conduct a servlet life initialization function, such as setting a counter. When a servlet is decommissioned, the servlet engine invokes the destroy() method in the servlet to allow the servlet to complete any remaining tasks and deallocate resources. This method can be overridden to write log messages or to wipe up any remaining connections that aren't picked up via garbage collection. The Application Server passes the incoming data to the servlet engine when a request is made. The servlet engine converts the request's input data into a HttpServletRequest request object type, which includes form data, cookies, session information, and URL name-value pairs. The HttpServletResponse response object type is also created by the servlet engine. Both are then passed as parameters to the servlet's service() procedure by the engine.

servlet引擎在servlet被实例化后调用servlet的init()方法,以执行任何必要的初始化。你可以覆盖此方法以执行servlet生命周期初始化功能,例如设置计数器。当servlet被停用时,servlet引擎调用servlet中的destroy()方法,以允许servlet完成任何剩余任务并释放资源。此方法可以被覆盖以写入日志消息或清除任何未被垃圾回收捕获的剩余连接。当发出请求时,应用服务器将传入数据传递给servlet引擎。servlet引擎将请求的输入数据转换为HttpServletRequest请求对象类型,其中包括表单数据、Cookie、会话信息和URL名称-值对。servlet引擎还创建HttpServletResponse响应对象类型。然后引擎将两者作为参数传递给servlet的service()过程。

77. What are the two roles of the CQ5 Dispatcher?

CQ5 Dispatcher 的两个角色是什么?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97507 | 官方: 否 | 付费: 否

答案:

There are two key functions within CQ5 dispatcher that should be highlighted: - Caching: The content on the website is cached as much as feasible in this role so that it can be used as a static website. It will lessen the layout engine's need to run repeatedly. The Dispatcher caches static items in a Cache Directory. The cached documents are created in the web server's root directory. For caching, Dispatcher employs the following techniques:

CQ5 dispatcher 中有两个关键功能值得强调: - 缓存:在此角色中,网站内容尽可能多地被缓存,以便其可用作静态网站。这将减少布局引擎重复运行的需求。Dispatcher 在缓存目录中缓存静态项目。缓存文档创建在 Web 服务器的根目录中。对于缓存,Dispatcher 采用以下技术:
Content Updates invalidates pages with updated content and replaces them with fresh content. Without physically removing any files, auto-invalidation automatically invalidates out-of-date content portions. - Load balancing: Load balancing is the process of dividing the website's computational load across many instances of AEM. This is used to improve the website's performance. This is how Dispatcher performs load balancing:
内容更新会使具有更新内容的页面失效,并用新内容替换它们。在不物理删除任何文件的情况下,自动失效会自动使过时的内容部分失效。 - 负载均衡:负载均衡是将网站的计算负载分配到多个 AEM 实例的过程。这用于提高网站性能。以下是 Dispatcher 执行负载均衡的方式:
Performance Statistics — Dispatcher keeps track of how quickly each instance of cq responds to a given url. Using these metrics, dispatcher determines which instance of cq will fetch the fastest response for any request and forwards the request to that instance. Sticky Connections — Once a user session has been established, all incoming requests from that user should be serviced by the same cq instance, as other cq instances will not be able to identify the user session and provide personalised pages for him. The dispatcher ensures that all user session requests are served from the same cq instance. Increased fail-safe coverage: If an instance does not respond, the Dispatcher will immediately relay requests to one of the other instances (s) Increased processing power: In reality, this means that the Dispatcher distributes document requests over multiple CQ instances. You get faster response times since each instance has fewer documents to process.
性能统计 — Dispatcher 跟踪每个 cq 实例对给定 url 的响应速度。使用这些指标,dispatcher 确定哪个 cq 实例将为任何请求获取最快的响应,并将请求转发到该实例。粘性连接 — 一旦建立了用户会话,来自该用户的所有传入请求应由同一个 cq 实例服务,因为其他 cq 实例将无法识别用户会话并为他提供个性化页面。dispatcher 确保所有用户会话请求都从同一个 cq 实例提供服务。增加故障安全覆盖:如果一个实例不响应,Dispatcher 将立即将请求转发到其他实例之一。增加处理能力:实际上,这意味着 Dispatcher 将文档请求分发到多个 CQ 实例。您会获得更快的响应时间,因为每个实例处理的文档更少。

78. What is an Adaptive Form and an Adaptive Document?

什么是自适应表单和自适应文档?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b9750a | 官方: 否 | 付费: 否

答案:

Adaptive forms are used to divide a form into logical portions, allowing end-users to concentrate solely on filling out the form. When we need to collect data from a user, we employ an adaptive form. You may develop forms that are interesting, responsive, dynamic, and adaptive with adaptive forms. For designing and dealing with adaptable forms, AEM Forms provides an easy user interface and out-of-the-box components. You have the option of creating an adaptive form with or without a form model or schema. It's critical to pick a form model that not only meets your needs but also extends your existing infrastructure investments and assets.

自适应表单用于将表单划分为逻辑部分,使最终用户能够专注于填写表单。当我们需要从用户那里收集数据时,我们使用自适应表单。您可以使用自适应表单开发有趣、响应式、动态和自适应的表单。对于设计和处理自适应表单,AEM Forms 提供了简单的用户界面和开箱即用的组件。您可以选择是否创建带有表单模型或架构的自适应表单。选择不仅能满足您的需求,还能扩展现有基础设施投资和资产的表单模型至关重要。

The output of the adaptive form is shown to the end-user via an Adaptive Document. A bank statement, for example, is an adaptive document because all of its content remains the same save for the name and amount. In an Adaptive Document, we basically set placeholder text that is filled dynamically at run time.

自适应表单的输出通过自适应文档展示给最终用户。例如,银行对账单是一种自适应文档,因为除了姓名和金额外,其所有内容保持不变。在自适应文档中,我们基本上设置占位符文本,这些文本在运行时动态填充。

79. In AEM, what is the benefit of using a tag?

在 AEM 中,使用标签有什么好处?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b9750d | 官方: 否 | 付费: 否

答案:

  • A tag is a piece of metadata that is attached to a piece of content. Tags can be used on pages as well as assets. Tags can be thought of as keywords or labels that an author assigns to content to make it simpler to locate, utilise, or comprehend.
  • Authors can use tagging to add keywords to their writing. Tags in AEM can be categorised into "namespaces," which are groups of tags. These namespaces are usually associated with a specific department's website. Each new site is given its own domain, but an institution-wide namespace is also utilised for categorising global assets like photographs and icons that are often used.
  • Tags are a useful way to organise your AEM pages and assets. You may make your assets (PDF documents, photos, etc.) easier to find with AEM's Content Finder by labelling them. As an author types a keyword into the Content Finder, a drop-down menu of suggested tags appears. After that, the author can pick that tag to see a list of all assets containing that tag.

80. Is it possible to prevent certain users from accessing certain digital assets?

是否有可能阻止某些用户访问某些数字资产?
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97510 | 官方: 否 | 付费: 否

答案:

You may always restrict who has access to certain folders in CQ Digital Assets by adding them to a CUG (closed user group).

您始终可以通过将用户添加到 CUG(封闭用户组)来限制谁可以访问 CQ Digital Assets 中的某些文件夹。

To make a folder a part of a CUG, follow these steps: - Right-click the folder for which you wish to add closed user group properties in CQ DAM and choose Properties.

要使文件夹成为 CUG 的一部分,请遵循以下步骤: - 在 CQ DAM 中,右键单击您想要添加封闭用户组属性的文件夹,并选择“属性”。
  • Select CUG from the drop-down menu.
  • To make the folder and its assets available only to a closed user group, use the Enabled checkbox.
  • To add that information, go to the login page, if one exists. By selecting Add item, you can add admitted groups. Add the realm if necessary. To save your changes, click OK.

81. You have a lot of brands – AND, ONLY, etc. – and a lot of pages for these brands in your AEM content structure. The site hierarchy for these brands cannot be segregated. For each of these brands, the client expects a particular theme.

您有许多品牌 — 例如 AND、ONLY 等 — 并且您的 AEM 内容结构中有许多针对这些品牌的页面。这些品牌的站点层次结构无法分离。对于每个品牌,客户期望特定的主题。
  • 知识点: 后端 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97513 | 官方: 否 | 付费: 否

答案:

I'd address the situation with the following suggestions: - Global Configuration Page: Make a Global Configuration Page (assuming Dynamic CSS) where consumers may specify which brand has which CSS/theme included. This configuration page can be used to select a specific brand, its CSS (either a set path or a zip package), its logo, and any other adjustments specific to that brand. The CSS file from this global configuration page would be picked up by all pages, which would then apply the theme based on the brand. Tags on the page, selectors for specific brands, or a pre-specified path could all be used to identify the brand.

我会用以下建议来处理这种情况: - 全局配置页面:创建一个全局配置页面(假设动态 CSS),消费者可以在此指定哪个品牌包含哪个 CSS/主题。此配置页面可用于选择特定品牌、其 CSS(可以是路径集或 zip 包)、其徽标以及任何特定于该品牌的其他调整。来自此全局配置页面的 CSS 文件将被所有页面拾取,然后根据品牌应用主题。页面上的标签、特定品牌的选择器或预先指定的路径都可用来识别品牌。
  • Consider Fixed CSS: If we have a fixed CSS file, we may map the Tags on the page directly to it. If a specific Tag (e.g. AND, ONLY) is present on the page, the CSS will be applied directly to that page. Tags could be created by CQ authors using Page attributes. Selectors can also be used to solve the problem.
  • Segregation: A better and ideal case would be to separate the brands in a site hierarchy so that a single theme could be applied to all pages under a node for a certain brand.

82. You're probably aware that anytime we upload a DAM asset to AEM, a back-end workflow is started. Now we need to upload approx 3000 dam assets of varying sizes to our AEM instance, and don't want to overload it with thousands of operations all at once.

您可能知道,每当我们向 AEM 上传 DAM 资产时,都会启动一个后端工作流。现在我们需要将大约 3000 个大小不一的 DAM 资产上传到我们的 AEM 实例,并且不希望一次用数千个操作使其过载。
  • 知识点: 后端 / 行为与软技能 (主题: aem, adobe;标签: interviewbit, aem, topic-specific, adobe)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3791c58d557c902b97516 | 官方: 否 | 付费: 否

答案:

The solution is discussed as follows: - Transfer from FileSystem to CQ instance: WebDAV (Web Distributed Authoring and Versioning) is commonly used to upload a huge number of digital assets. WebDAV is a set of Hypertext Transfer Protocol (HTTP) extensions. It allows user agents to collaboratively write content straightforwardly in an HTTP web server by offering concurrency control and namespace operations. WebDAV is a protocol that allows users to create, edit, and move documents on a server.

解决方案讨论如下: - 从文件系统传输到 CQ 实例:WebDAV(Web 分布式创作和版本控制)通常用于上传大量数字资产。WebDAV 是一组超文本传输协议(HTTP)扩展。它通过提供并发控制和命名空间操作,允许用户代理直接在 HTTP Web 服务器上协作编写内容。WebDAV 是一种允许用户在服务器上创建、编辑和移动文档的协议。
  • Transfer from one CQ instance to another: To move content from one CQ instance to another, CQ provides a number of alternatives. "Replication" (author->publish) and "create package->export->install somewhere" are two examples. The File Vault (vlt) tool also offers a Remote Copy (rcp) feature, which comes in handy when moving GB or TB of digital assets (JCR node type dam:Asset) from DEV to STAGING to PRODUCTION. When transferring DAM assets from one instance to another, be careful to disable DAM workflow.
    Conclusion:

    结论:

Digitization has become a necessity for organisations to stay afloat in the long run. As a result, digital content management solutions like AEM are in high demand. The widespread adoption of AEM tools has resulted in additional employment openings for trained individuals. I hope you found this blog post on AEM to be helpful.

数字化已成为组织长期生存的必要条件。因此,像 AEM 这样的数字内容管理解决方案需求很高。AEM 工具的广泛采用为受过培训的个人带来了更多的就业机会。我希望您发现这篇关于 AEM 的博客文章对您有帮助。

We recommend reading,

我们建议阅读,

Interview questions on Adobe

Adobe 相关面试问题

AEM Download

AEM 下载

83. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Afterpay BNPL(Buy Now Pay Later)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: afterpay, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Afterpay (Block)
  • id: 69b3791f58d557c902b977dd | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

84. 解释 RESTful API(RESTful API)设计的最佳实践,以及在ANZ Plus中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: anz, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: 澳新银行
  • id: 69b3793a58d557c902b9909f | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

85. Define cache coherence and hypercube connection. For a node hypercube, what will be its diameter?

定义缓存一致性和超立方体连接。对于一个节点超立方体,它的直径是多少?
  • 知识点: 后端 (标签: interviewbit, arcesium, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Arcesium
  • id: 69b3793e58d557c902b993f6 | 官方: 否 | 付费: 否

答案:

Cache coherence simply means that different processors might keep their own local caches. As a result, there could be several copies of the same data. Access to the local copies behaves similarly to access from the local copies, with the exception of access time. A hypercube is a single node. An n node hypercube is made up of two n/2 node hypercubes connected by their respective nodes. An n node hypercube has a diameter of log(n). The diameter is nothing but the smallest number of links needed to connect the two farthest nodes.

缓存一致性简单来说就是不同的处理器可能保留各自的本地缓存。因此,同一数据可能存在多个副本。对本地副本的访问行为与从本地副本访问类似,只是访问时间不同。超立方体是单个节点。一个 n 节点超立方体由两个 n/2 节点超立方体通过它们各自的节点连接而成。一个 n 节点超立方体的直径为 log(n)。直径不过是连接两个最远节点所需的最小链路数。

86. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Jira(Jira)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: atlassian, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: design
  • 公司: Atlassian
  • id: 69b3794b58d557c902b99e78 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

87. 什么是微服务架构(Microservices Architecture)?与单体架构(Monolithic Architecture)相比有哪些优缺点?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, system-design;标签: atlassian, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: design
  • 公司: Atlassian
  • id: 69b3794b58d557c902b99e7b | 官方: 是 | 付费: 是

答案:

思路分析从服务拆分(Service Decomposition)、独立部署(Independent Deployment)、数据隔离(Data Isolation)、通信方式(Communication Mechanism)等维度对比。
参考答案优点:独立部署(Independent Deployment)、技术多样性(Technology Diversity)、弹性伸缩(Elastic Scaling)、团队自治(Team Autonomy)。缺点:分布式复杂性(Distributed Complexity)、服务间通信开销(Inter-Service Communication Overhead)、数据一致性挑战(Data Consistency Challenges)、运维复杂度增加(Operational Complexity Increase)。
评分要点- 理解何时应该使用微服务(Microservices)

  • 服务拆分原则(DDD)
  • 分布式事务处理方案
    常见追问- Jira(Jira)是如何做微服务拆分的?
  • 如何处理微服务间的数据一致性?

88. What is "AWS Lambda"?

什么是“AWS Lambda”?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab65 | 官方: 否 | 付费: 否

答案:

Lambda, a software service platform offered by Amazon Web Services, is an example of this type of platform. Lambda enables serverless computing in specific scenarios. Events generated by AWS can be used to initiate the execution of code in any application.

Lambda是亚马逊网络服务提供的软件服务平台,是这类平台的一个例子。Lambda在特定场景下实现无服务器计算。AWS生成的事件可用于启动任何应用程序中的代码执行。

You have access to a wide range of AWS services, including the Amazon Simple Storage Service (S3) for storing files, the Amazon DynamoDB for updating tables, the Amazon API Gateway for gaining access, and many more. AWS Lambda frees developers from the burden of configuring and managing software servers, allowing them to focus on writing and running their programmes.

你可以访问广泛的AWS服务,包括用于存储文件的Amazon Simple Storage Service(S3)、用于更新表的Amazon DynamoDB、用于获取访问权限的Amazon API Gateway等。AWS Lambda使开发者免于配置和管理软件服务器的负担,让他们专注于编写和运行程序。

89. Is there a programming language that AWS Lambda is not compatible with?

是否存在AWS Lambda不兼容的编程语言?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab68 | 官方: 否 | 付费: 否

答案:

AWS Lambda allows for the use of the following programming languages: C#, .NET, Node.js, Javascript, Java (version 8), and Go. These programming languages already have their libraries and other built-in features set up and ready to go.

AWS Lambda允许使用以下编程语言:C#、.NET、Node.js、Javascript、Java(版本8)和Go。这些编程语言已经将其库和其他内置功能设置并准备好使用。

90. What are the procedures for entering EC2?

进入EC2的步骤是什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab6b | 官方: 否 | 付费: 否

答案:

Users are able to connect to EC2 with either a command-line interface or a web-based interface. A further benefit of using AWS lambda is that it equips Windows power shells with the necessary tools.

用户可以通过命令行界面或基于Web的界面连接到EC2。使用AWS Lambda的另一个好处是它为Windows PowerShell配备了必要的工具。

91. What are the constraints that AWS lambda function imposes?

AWS lambda函数施加了哪些限制?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab6e | 官方: 否 | 付费: 否

答案:

AWS Lambda imposes only a few light constraints on the kinds of things that may be done with an operating system and the kinds of programming languages that can be used with it. You cannot simply cease doing things like creating instances, tracking phone calls, or blocking incoming network connections.

AWS Lambda 对操作系统可执行的操作类型及可使用的编程语言仅施加了少量宽松限制。你不能简单停止诸如创建实例、跟踪电话或阻止传入网络连接之类的操作。

These activities are not possible. While you're doing it, you should disable things like the system debugger and any TCP ports (More than 25 traffic available to measure the anti-spam). When it comes to establishing connections with the wider world, IP/TCP sockets are an extremely handy tool.

这些活动是不可能的。在操作过程中,你应该禁用系统调试器及任何TCP端口(超过25个流量可用于测量反垃圾邮件)。当涉及与外界建立连接时,IP/TCP套接字是极为便捷的工具。

92. Which capabilities of AWS lambda contribute to the automation of the deployment process?

AWS Lambda 的哪些能力有助于自动化部署过程?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab71 | 官方: 否 | 付费: 否

答案:

A diverse range of environments is available for use with AWS Lambda. You can use these configurations to retrieve the appropriate data and user credentials in the event that you need to make modifications to your deployment packages, but do not have access to the original packages.

AWS Lambda 可使用多种多样的环境。你可以利用这些配置,在需要修改部署包但无法访问原始包时,检索适当的数据和用户凭据。

Aliases are something that can be used with AWS Lambda, which is a serverless technique. This is something that is already common information. It is not difficult to take into account the many AWS Lambda variants throughout the pre-production phase and the development of an application.

别名可与 AWS Lambda(一种无服务器技术)一起使用,这已是常见知识。在预生产阶段和应用程序开发过程中,考虑多种 AWS Lambda 变体并不困难。

As a consequence of this, the Lambda function can be considered for testing without seriously affecting the user code when it is being run in production. It is not important how you do the work as long as you follow the plan and do it in the correct sequence.

因此,可以在生产环境中运行时考虑对 Lambda 函数进行测试,而不会严重影响用户代码。只要遵循计划并按正确顺序执行,工作方式并不重要。

93. What is the maximum execution time allowed for an AWS Lambda function to be customised?

AWS Lambda 函数允许自定义的最大执行时间是多少?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab74 | 官方: 否 | 付费: 否

答案:

The entirety of the execution will be finished within three hundred seconds of the first user call being made to AWS lambda. The length of timeouts can be customized anywhere from 1 and 300 seconds, with 3 seconds serving as the default value.

从首次用户调用 AWS Lambda 起,整个执行将在三百秒内完成。超时时间长度可在1到300秒之间自定义,默认值为3秒。

94. What are the available frameworks for the serverless approach?

无服务器方法有哪些可用的框架?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab77 | 官方: 否 | 付费: 否

答案:

There are currently a number of powerful serverless frameworks available. They provide outstanding customer service, an open-source whisk, and capabilities for Microsoft Azure, all of which contribute to their product's high level of user-friendliness.

目前有多种强大的无服务器框架可用。它们提供卓越的客户服务、开源 whisk 以及 Microsoft Azure 的功能,这些都有助于其产品的高用户友好性。

During the process of constructing a cloud infrastructure, the concept of serverless application software is only taken into consideration. The AWS Lambda Application Programming Interface (API) makes scripting a snap, which in turn makes complicated processes more manageable and reliable.

在构建云基础设施过程中,无服务器应用软件的概念才被考虑。AWS Lambda 应用程序编程接口(API)使脚本编写变得简单,从而使复杂流程更易管理且更可靠。

95. For instance, how can Amazon Elastic Compute Cloud (AWS Lambda) guarantee the safety of my programmes?

例如,Amazon Elastic Compute Cloud (AWS Lambda) 如何保证我程序的安全?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab7a | 官方: 否 | 付费: 否

答案:

The user codes for AWS Lambda can be saved in Amazon S3, and after that, they can be encrypted by following the necessary steps. During the processing, additional tests on the data's integrity are performed by using AWS Lambda.

AWS Lambda 的用户代码可保存在 Amazon S3 中,之后可按必要步骤进行加密。在处理过程中,通过使用 AWS Lambda 对数据的完整性执行额外测试。

96. How long may a lambda function in AWS be allowed to run before it is considered a DDOS attack?

AWS 中的 lambda 函数在被视为 DDOS 攻击之前可以运行多久?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab7d | 官方: 否 | 付费: 否

答案:

DDOS attacks are possible with AWS lambda, but you only have five minutes to complete the process.

AWS lambda 可能遭受 DDOS 攻击,但你只有五分钟来完成此过程。

97. What is meant by the term "auto-scaling"?

“自动缩放”一词是什么意思?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab80 | 官方: 否 | 付费: 否

答案:

Simply said, auto-scaling in AWS lambda is a function of the Amazon web service that enables users to start new instances of a service and carry out any necessary configuration chores without having to manually interfere.

简而言之,AWS Lambda 中的自动扩展是亚马逊网络服务的一项功能,它使用户能够启动服务的新实例并执行任何必要的配置任务,而无需手动干预。

This function enables users to save time and effort. You are free to relax and see how the installation is carried out while keeping a close check on the threshold and key performance indicators as they appear in real-time. In other circumstances, all that is required of you is to cross the threshold in order to instantly begin the work and any instances related to it. This entails no additional horizontal disruption.

此功能使用户能够节省时间和精力。您可以放松并观察安装过程,同时实时密切关注阈值和关键性能指标。在其他情况下,您只需跨越阈值即可立即开始工作及其相关实例。这不会带来额外的水平中断。

98. What are your thoughts on the concept of payments that have no downtime?

您对无停机付款的概念有何看法?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab83 | 官方: 否 | 付费: 否

答案:

For deployment purposes, Lambda on AWS often makes use of instance functions. In addition, if the programmes are exceptionally difficult to understand, the AWS lambda framework can be segmented into more manageable parts. In reality, the application is inaccessible online while it is doing a process because that takes some amount of time. The finished thing turned out quite well.

出于部署目的,AWS 上的 Lambda 通常利用实例函数。此外,如果程序极其难以理解,AWS Lambda 框架可以分割成更易于管理的部分。实际上,应用程序在执行某个过程时无法在线访问,因为那需要一定时间。最终结果相当不错。

99. Is there access available to the servers that AWS lambda uses by the general public?

公众是否可以访问 AWS Lambda 使用的服务器?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab86 | 官方: 否 | 付费: 否

答案:

The answer is not positive, to put it succinctly. With the release of AWS Lambda, it is now possible to use the cloud computing infrastructure to carry out activities without requiring any input from the user. In addition to this, there is no way to access the Lambda infrastructure. Because of the way that this arrangement is configured, Lambda is able to perform preventative maintenance, check its health, and update its security measures.

简而言之,答案是否定的。随着 AWS Lambda 的发布,现在可以使用云计算基础设施来执行活动,而无需用户任何输入。此外,无法访问 Lambda 基础设施。由于这种安排的配置方式,Lambda 能够执行预防性维护、检查其健康状况并更新其安全措施。

100. Kindly clarify what the EC2 services are?

请澄清一下 EC2 服务是什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab89 | 官方: 否 | 付费: 否

答案:

Aws Lambda requires scalable computational capabilities so that it can process user data in the cloud. Managing EC2 is just as easy as managing any other online service, and all of the same measures for network security should be taken. Using this strategy, configuring capacity and working with EC2 with as little effort as feasible is achievable.

AWS Lambda 需要可扩展的计算能力,以便在云端处理用户数据。管理 EC2 与管理任何其他在线服务一样简单,并且应采取所有相同的网络安全措施。使用此策略,以尽可能少的努力配置容量和处理 EC2 是可以实现的。

101. What do you think about the idea of using packages with AWS lambda?

您对在 AWS Lambda 中使用软件包的想法有何看法?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab8c | 官方: 否 | 付费: 否

答案:

In AWS Lambda, it is very natural for user-created packages as well as NPM packages to be utilized efficiently.

在 AWS Lambda 中,用户创建的软件包以及 NPM 软件包被高效利用是非常自然的。

102. What is "AMI" in AWS Lambda?

AWS Lambda 中的“AMI”是什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab8f | 官方: 否 | 付费: 否

答案:

Amazon Machine Image is referred to by its acronym, AMI, and is utilized rather commonly in Lambda-based processing. In its most basic form, it is a starting point that has commonly used software such as an operating system, an application server, and potentially some extra programs already installed on it.

Amazon Machine Image 以其缩写 AMI 指代,并在基于 Lambda 的处理中被相当普遍地使用。其最基本的形式是一个起点,其中已安装了常用软件,如操作系统、应用程序服务器,可能还有一些额外的程序。

The duplicate in the cloud can be created because it already has several copies and can handle running multiple instances at the same time. In addition, the Amazon Machine image can be used to run a virtual server that is hosted in the cloud.

云端中的副本可以创建,因为它已有多个副本,并能同时处理运行多个实例。此外,Amazon Machine Image 可用于运行托管在云端的虚拟服务器。

103. What are the limits of the availability of lambda functions on Amazon Web Services?

在亚马逊网络服务上,lambda 函数的可用性限制是什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab92 | 官方: 否 | 付费: 否

答案:

The lambda application hosted on Amazon Web Services makes use of redundancy and replication to ensure that your lambda and Amazon services continue to run without interruption. In addition, the management of Amazon Lambda's downtime and maintenance windows is incorporated into this offering.

托管在亚马逊网络服务上的 lambda 应用程序利用冗余和复制,以确保您的 lambda 和亚马逊服务持续运行而不中断。此外,Amazon Lambda 的停机时间和管理维护窗口的管理也整合在此服务中。

104. What are the various storage choices that are available through Amazon?

通过亚马逊可用的各种存储选择有哪些?
  • 知识点: 后端 / DevOps/云 / 行为与软技能 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab95 | 官方: 否 | 付费: 否

答案:

Amazon Lambda is designed to work with a broad range of storage alternatives, but the most important thing to keep in mind is that every one of these choices offers the highest possible level of dependability and productivity. There is no logical impediment to employing both of them in tandem. Access can also be gained without the use of a guide or assistant.

Amazon Lambda 旨在与广泛的存储选项配合使用,但最重要的一点是,这些选项中的每一个都提供了最高级别的可靠性和生产力。将两者结合使用没有逻辑上的障碍。访问也可以在没有指南或助手的情况下实现。

I'll only list a few, but one of them is Elastic Block Storage (EBS), which is a method for storing data that utilizes block-level storage. If separate storage is required, this product, which comes with built-in encryption features, is one option that could be considered. The subsequent type is known as an EC2 instance, and it operates very similarly to a storage disc that is directly connected to the host computer.

我只列举几个,其中之一是弹性块存储(EBS),这是一种利用块级存储来存储数据的方法。如果需要单独的存储,这个自带加密功能的产品是一个可以考虑的选项。下一种类型称为EC2实例,其工作原理与直接连接到宿主机的存储磁盘非常相似。

This form of storage is designed for use over a relatively short period of time, as the name suggests. After some time has gone by, the user has the opportunity to consider whether or not the financial investment in good storage is worthwhile. The user data will continue to be valid so long as the instances themselves continue to be valid. The next option is for adding storage, which is effectively the user's root storage and can be utilized for running instances.

顾名思义,这种存储形式设计用于相对较短的时间段。过了一段时间后,用户有机会考虑在优质存储上的财务投资是否值得。只要实例本身保持有效,用户数据将继续有效。下一个选项是添加存储,这实际上是用户的根存储,可用于运行实例。

This will almost always include data pertaining to the boot instance. Following that, Amazon Simple Storage Service (S3) -> is another type of AWS lambda storage that enables users to store an unlimited quantity of data at an affordable cost.

这几乎总是包含与启动实例相关的数据。接下来,Amazon Simple Storage Service (S3) -> 是另一种AWS lambda存储类型,允许用户以可承受的成本存储无限量的数据。

105. Is there a maximum limit that has been predetermined and that needs to be adhered to in any way?

是否存在一个预定好的最大限制,需要以任何方式遵守?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab99 | 官方: 否 | 付费: 否

答案:

The account level is the only place where the default limit for AWS lambda is enforced. At the functional level, there is no limit that is predetermined.

AWS lambda的默认限制仅在账户级别强制执行。在功能级别,没有预定的限制。

106. What exactly is meant by the term "elastic blocker" when referring to AWS lambda?

在AWS lambda中,术语“弹性块”具体指什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9ab9d | 官方: 否 | 付费: 否

答案:

Users can make use of the elastic storage, which is effectively a digital file cabinet, in order to get started with the networking-related responsibilities that need to be completed. The user does not need to be concerned about the possibility of data loss due to a damaged disc as long as the RAID array is in good health.

用户可以利用弹性存储(实质上是一个数字文件柜)来开始处理需要完成的网络相关任务。只要RAID阵列健康,用户无需担心因磁盘损坏而导致数据丢失的可能性。

The storage in question also supports the process of allocating and provisioning memory space. On occasion, a connection can be made between this and the application programming interface that exists on a node that serves a specific purpose.

所涉及的存储还支持分配和提供内存空间的过程。有时,这可能与存在于特定用途节点上的应用程序编程接口建立连接。

107. How can we automate apps that do not require a server?

如何自动化不需要服务器的应用程序?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9aba0 | 官方: 否 | 付费: 否

答案:

Following the completion of the serverless application development with AWS Lambda, the automated procedure is then released, and the application is then deployed. Because of this, the serverless application can be deployed with the help of the AWS code pipeline, a continuous form of service delivery that enables the required modeling, data visualization, and automation of activities.

完成使用AWS Lambda的无服务器应用程序开发后,自动化过程发布,然后部署应用程序。因此,借助AWS代码管道,可以部署无服务器应用程序,这是一种持续形式的服务交付,能够实现所需的建模、数据可视化和活动自动化。

Automated code deployment for lambda-based applications is also on the roadmap for AWS code deployment. This enables the user to coordinate deployments in accordance with best practice application methodologies, such as a canary deployment and a linear deployment, which helps verify that the newly created deployment programme is safe, reliable, and fit for use at an industrial level.

针对基于lambda的应用程序的自动化代码部署也列在AWS代码部署的路线图中。这使用户能够根据最佳实践应用程序方法(如金丝雀部署和线性部署)协调部署,有助于验证新创建的部署程序在工业级使用中是安全、可靠且适用的。

108. How do I build my first serverless app?

如何构建我的第一个无服务器应用?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9aba3 | 官方: 否 | 付费: 否

答案:

In order to get started with serverless applications, you will need to access the AWS Lambda dashboard and save the blueprint. This file's original version will be downloaded, and it should include both an AWS Sam file (which the programme refers to as an AWS resource) and a ZIP file (which mostly included the function code). With the assistance of the AWS Cloud Formation commands, you will be able to successfully complete tasks such as documenting your serverless apps and deploying them.

要开始使用无服务器应用程序,您需要访问AWS Lambda仪表板并保存蓝图。将下载此文件的原始版本,它应包含一个AWS Sam文件(程序将其称为AWS资源)和一个ZIP文件(其中主要包含函数代码)。在AWS Cloud Formation命令的帮助下,您将能够成功完成诸如记录无服务器应用程序和部署它们等任务。

109. What is SQS and what does it perform in relation to AWS lambda?

什么是SQS,它在AWS lambda中执行什么功能?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9aba6 | 官方: 否 | 付费: 否

答案:

A way of sharing data between various hosts on a local network and network endpoints is what the Simple Queue Service (SQS) in AWS lambda is all about. SQS makes it possible for applications to communicate with one another and provides users with access to lambda's many different functions.

AWS lambda中的简单队列服务(SQS)是一种在本地网络上的各种主机和网络端点之间共享数据的方式。SQS使应用程序能够相互通信,并为用户提供访问lambda多种不同功能的能力。

It makes no difference which functional components you make use of because they are all connected to one another. As a consequence of this, a failure mechanism is no longer required, and the ability of individual elements to communicate with one another has been significantly improved.

使用哪些功能组件并不重要,因为它们都相互连接。因此,不再需要故障机制,各个元素之间相互通信的能力也得到了显著提高。

110. What actions should I take to fix my app that does not require a server?

我应该采取哪些措施来修复我的无需服务器的应用程序?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9aba9 | 官方: 否 | 付费: 否

答案:

AWS x-ray can be used to activate an AWS lambda function for tracking by first providing x-ray access to lambda functional roles for execution and then setting the function's "mode of code tracing" to active.

AWS x-ray 可用于激活 AWS lambda 函数以进行跟踪,方法是首先为 lambda 功能角色提供 x-ray 访问权限以执行,然后将函数的“代码跟踪模式”设置为激活。

When a user activates X-RAY for lambda functional components, the system starts recording various amounts of information, including the amount of time spent on each lambda service, the overall amount of time spent on all lambda services, the duration of each functional execution, and more. There are X-ray software development kits (SDKs) available right now for both Node.js and Java.

当用户为 lambda 功能组件激活 X-RAY 时,系统开始记录各种信息量,包括在每个 lambda 服务上花费的时间、在所有 lambda 服务上花费的总时间、每次功能执行的持续时间等。目前有适用于 Node.js 和 Java 的 X-ray 软件开发工具包(SDK)。

111. If adjustments are made to the code or configuration, will the AWS lambda-based function still be accessible after these changes have been made?

如果对代码或配置进行了调整,基于 AWS lambda 的函数在这些更改之后是否仍然可以访问?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abac | 官方: 否 | 付费: 否

答案:

If you're wondering whether or not an update to an AWS lambda function will cause a brief interval (less than a minute) during which requests can be fulfilled by either the old or new version of the lambda functions, the answer is yes. If you're wondering whether or not an update to an AWS lambda function will cause a brief interval (less than a minute), the answer is yes.

如果你想知道对 AWS lambda 函数的更新是否会导致一个短暂间隔(不到一分钟),在此期间请求可以由旧版或新版 lambda 函数处理,答案是肯定的。如果你想知道对 AWS lambda 函数的更新是否会导致一个短暂间隔(不到一分钟),答案也是肯定的。

112. Is there a limit to the number of AWS lambda functions that can run in parallel at the same time?

AWS lambda 函数可以同时并行运行的数量是否有限制?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abaf | 官方: 否 | 付费: 否

答案:

Because the AWS lambda application was designed to work only on certain instances of functional codes, the answer is "no." In addition, there is a default safety threshold in AWS lambda for a specific number of consecutive executions for each subscription. This barrier is based on the number of executions.

因为 AWS lambda 应用程序设计为仅在特定功能代码实例上运行,所以答案是“否”。此外,AWS lambda 中每个订阅的连续执行次数有一个默认的安全阈值。这个障碍基于执行次数。

You will be able to save your most important resources for the times when they are required the most if you restrict the number of times that a single AWS function can execute a lambda in succession.

如果你限制单个 AWS 函数连续执行 lambda 的次数,你将能够在最需要的时刻保存最重要的资源。

113. What will happen if the total amount of my execution goes beyond the normal limit?

如果我的总执行量超过正常限制,会发生什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abb2 | 官方: 否 | 付费: 否

答案:

The AWS Lambda functions are called in real time whenever the threshold is exceeded, and the threshold error is returned (429 errors –code). A substantial quantity of traffic may be handled by Lambda functions for 15–30 minutes at a time, and they can be run asynchronously in order to fulfil their primary objectives. The operation will come to a close by filtering out and slowing down upcoming events.

当阈值被超过时,AWS Lambda 函数会实时被调用,并返回阈值错误(429 错误代码)。Lambda 函数一次可以处理大量流量,持续 15–30 分钟,并且可以异步运行以实现其主要目标。操作将通过过滤和减慢即将到来的事件来结束。

After the AWS lambda function that manages the configuration has suppressed it, the storage tool will no longer be able to get it to respond to Amazon S3 events. The vast bulk of the events is supplied by Amazon Kinesis, Amazon DynamoDB, and the data that has been deprecated. The fact that Amazon Kinesis and Amazon DB events preserve data for more than twenty-four hours makes them extremely useful.

在管理配置的 AWS lambda 函数抑制后,存储工具将不再能使其响应 Amazon S3 事件。绝大多数事件由 Amazon Kinesis、Amazon DynamoDB 和已弃用的数据提供。Amazon Kinesis 和 Amazon DB 事件保留数据超过二十四小时这一事实使它们非常有用。

114. What is a Serverless Application?

什么是无服务器应用程序?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abb5 | 官方: 否 | 付费: 否

答案:

The serverless applications are lambda-based, which means that they are made up of functions that are triggered into action in response to particular events. Every one of the functional events, such as an item being uploaded to Amazon S3, an Amazon SNS message being received, or an API request being made, will activate one or more functions in the default serverless application.

无服务器应用程序基于 lambda,这意味着它们由响应特定事件而触发行动的函数组成。每一个功能事件,例如将项目上传到 Amazon S3、接收 Amazon SNS 消息或发出 API 请求,都会激活默认无服务器应用程序中的一个或多个函数。

These methods can function independently, making use of other Amazon Web Services (AWS) technologies such as DynamoDB tables and S3 buckets. The most popular kind of serverless application is called a function.

这些方法可以独立运行,利用其他亚马逊网络服务(AWS)技术,如 DynamoDB 表和 S3 存储桶。最常见的无服务器应用程序类型称为函数。

115. How might we benefit if we did away with the requirement of having a server?

如果我们取消了拥有服务器的要求,我们有什么好处?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abb8 | 官方: 否 | 付费: 否

答案:

The following is a list of the primary advantages of using the Serverless method:

以下是使用 Serverless 方法的主要优势列表:
  1. To get things started, the uncomplicated procedures of the Serverless technique provide a quicker time to market and an increase in revenue. 2. The user is only charged for the code while it is being compiled, and by increasing earnings, many expenses can be avoided. 3. You are able to simply manage the smaller applications that make up the larger program, and you have the appropriate infrastructure in place to back it up.

    1. 首先,Serverless 技术的简单流程提供了更快的上市时间和收入的增加。 2. 用户仅在代码编译时被收费,并且通过增加收益,许多费用可以被避免。 3. 您能够轻松管理组成更大程序的较小应用程序,并且拥有适当的基础设施来支持它。

116. What exactly are the drawbacks of deciding to follow the road of serverless computing?

决定走 serverless 计算这条路究竟有哪些缺点?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abbb | 官方: 否 | 付费: 否

答案:

  • There are advantages and disadvantages to utilizing each component of AWS lambda, and these aspects change according to the type of work that is being carried out.
  • In the serverless paradigm, scalability is totally dependent on the vendor, therefore there is an increased chance for outages. Additionally, the serverless model has a higher failure rate.
  • The elimination of functionality and the introduction of new limitations are two examples of common issues. In addition, the serverless method of Amazon Web Services does not make use of any specialized hardware in any way.
  • Problems are frequently brought about by the blunders made by the customer.

117. What is the main difference between an anonymous class and a lambda function?

匿名类和 lambda 函数之间的主要区别是什么?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abbe | 官方: 否 | 付费: 否

答案:

The fundamental difference is in the emphasis that is placed on a number of different phrases. Keywords are utilized by lambda functions so that they can successfully resolve the functional classes. On the other hand, keywords are employed in order to resolve the anonymous functional class within the anonymous class.

根本区别在于对多个不同短语的强调重点。lambda 函数利用关键字来成功解析功能类。另一方面,在匿名类中使用关键字来解析匿名功能类。

118. What exactly does it mean to have anything "automated" when it comes to deployment?

在部署方面,“自动化”究竟是什么意思?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abc1 | 官方: 否 | 付费: 否

答案:

It operates in a manner not dissimilar to how the code of other languages does. Although this did not completely get rid of all of the problems, it did greatly cut down on them. The most enjoyable aspect is establishing a pipeline, which can be done rapidly if one has gained sufficient experience and expertise.

它的运作方式与其他语言代码的运作方式并无二致。虽然这并未完全消除所有问题,但确实大大减少了它们。最有趣的部分是建立流水线,如果获得了足够的经验和专业知识,这可以迅速完成。

Automated Deployment helps businesses ensure the best quality and most optimal results possible by removing the need for human intervention, which is a requirement for manual deployment.

自动化部署通过移除人工干预的需要(这是手动部署的要求),帮助企业确保尽可能最佳的质量和最优的结果。

119. How does AWS lambda facilitate deployment automation?

AWS lambda 如何促进部署自动化?
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abc4 | 官方: 否 | 付费: 否

答案:

You are able to use environment-specific variables when working with AWS lambda. They are able to be used for either data or a variety of credentials while the deployment package is being modified. Aliases are also compatible with this strategy despite the fact that it does not require a server. In point of fact, some of the areas, such as theatrical production and development, are quite straightforward to consider. This makes it easy to think about different testing approaches without actually affecting the code that is now being run. Because the destination is known in advance, it is possible to make rapid headway.

在使用 AWS lambda 时,您能够使用特定于环境的变量。在修改部署包时,它们可以用于数据或各种凭据。别名也与这一策略兼容,尽管它不需要服务器。事实上,某些区域(如生产环境和开发环境)非常容易考虑。这使得在不影响当前运行代码的情况下,容易思考不同的测试方法。由于目标事先已知,因此可以取得快速进展。

120. Explain the many different serverless frameworks that are available.

解释许多可用的不同 serverless 框架。
  • 知识点: 后端 / DevOps/云 (主题: aws, lambda, serverless;标签: interviewbit, aws-lambda, topic-specific, aws, lambda, serverless)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b3795b58d557c902b9abcb | 官方: 否 | 付费: 否

答案:

There are a variety of frameworks available, with serverless being one of the most powerful. Because it offers such remarkable assistance for Lambda and open whisk operations in addition to azure functions, it is without a doubt the very best of the very best.

有各种各样的框架可用,其中 serverless 是最强大的之一。因为除了 azure 函数外,它还为 Lambda 和 open whisk 操作提供了非凡的支持,所以毫无疑问它是最优秀的。

When expanding a cloud infrastructure, a simple alternative is to use something called the Serverless Application Model. Using this way, scripting API updates are made incredibly simple, and the best part is that the process can be completed quickly and reliably.

在扩展云基础设施时,一个简单的选择是使用称为 Serverless 应用程序模型的东西。通过这种方式,脚本 API 更新变得极其简单,而且最棒的是这个过程可以快速且可靠地完成。

121. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Mining Operations(Mining Operations)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: bhp, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: 必和必拓集团
  • id: 69b3797658d557c902b9c1a4 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

122. 解释 RESTful API(Application Programming Interface)设计的最佳实践,以及在Buildkite Pipelines(Buildkite Pipelines)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: buildkite, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Buildkite
  • id: 69b3799758d557c902b9d8e7 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

123. 解释 RESTful API(Representational State Transferful Application Programming Interface) 设计的最佳实践,以及在Canva Editor中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: canva, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: design
  • 公司: 可画
  • id: 69b379ce58d557c902ba0099 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

124. 解释 RESTful API(Representational State Transferful Application Programming Interface) 设计的最佳实践,以及在CommBank App中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: cba, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Commonwealth Bank of Australia
  • id: 69b37a0e58d557c902ba29bf | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

125. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Cochlear Implants(人工耳蜗)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: cochlear, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Cochlear
  • id: 69b37a2a58d557c902ba3c09 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

126. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Coles Online(Coles Online)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: coles, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Coles Group
  • id: 69b37a4658d557c902ba4d6a | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

127. What are the various annotations that Spring Boot Offers?

Spring Boot 提供了哪些各种注解?
  • 知识点: 后端 (标签: interviewbit, dassault-systemes, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: 达索系统
  • id: 69b37a5b58d557c902ba5bed | 官方: 否 | 付费: 否

答案:

Spring Boot offers several annotations that can be used to quickly set up and configure a Spring application. Some of the most commonly used annotations include:

Spring Boot 提供了多个注解,可用于快速设置和配置 Spring 应用程序。一些最常用的注解包括:
  1. @SpringBootApplication: This annotation is a convenience annotation that is used to enable several features in a Spring Boot application, including auto-configuration, component scanning, and making the class a configuration class for Spring Boot. 2. @Configuration: This annotation is used to indicate that a class is a configuration class for a Spring application. It tells the Spring framework that this class contains beans that need to be managed by the Spring container. 3. @Bean: This annotation is used to indicate that a method will return a bean that should be managed by the Spring container. It can be used in conjunction with @Configuration to create and configure beans for the application. 4. @Component: This annotation is used to indicate that a class is a component that should be managed by the Spring container. It can be used on any class, including @Configuration classes. 5. @Autowired: This annotation is used to indicate that a constructor, field, or setter method should be autowired with a matching bean in the Spring container. 6. @Value: This annotation is used to assign a value from application.properties or other property sources to a field, constructor, or setter method. 7. @Service: This annotation is a specialization of @Component and is used to indicate that a class is a service component, and it should be managed by the Spring container. 8. @Repository: This annotation is a specialization of @Component and is used to indicate that a class is a repository component, and it should be managed by the Spring container. 9. @Controller: This annotation is a specialization of @Component and is used to indicate that a class is a controller component, and it should be managed by the Spring container. 10. @RequestParam: This annotation is used to bind a request parameter to a method parameter in a Spring application. This annotation can be used to define the required parameter, default value, and whether the parameter is mandatory or not. 11. @PathParam: This annotation is used to bind a URL path parameter to a method parameter in a Spring application. This annotation can be used to define the required parameter and whether it is mandatory or not. 12. @SpringBootTest: This annotation is used to perform integration tests on a Spring Boot application. This annotation can be used to test the entire application context, including the controllers, services, and repositories. It can be used to verify the behavior of the application as a whole and to ensure that all components are functioning correctly.

    1. @SpringBootApplication:此注解是一个便捷注解,用于在 Spring Boot 应用程序中启用多项功能,包括自动配置、组件扫描,并将该类设为 Spring Boot 的配置类。 2. @Configuration:此注解用于表示某个类是 Spring 应用程序的配置类。它告诉 Spring 框架,该类包含需要由 Spring 容器管理的 bean。 3. @Bean:此注解用于表示某个方法将返回一个应由 Spring 容器管理的 bean。它可以与 @Configuration 一起使用,为应用程序创建和配置 bean。 4. @Component:此注解用于表示某个类是一个应由 Spring 容器管理的组件。它可用于任何类,包括 @Configuration 类。 5. @Autowired:此注解用于表示构造函数、字段或 setter 方法应使用 Spring 容器中匹配的 bean 进行自动装配。 6. @Value:此注解用于将 application.properties 或其他属性源中的值赋给字段、构造函数或 setter 方法。 7. @Service:此注解是 @Component 的一种特化,用于表示某个类是服务组件,并且应由 Spring 容器管理。 8. @Repository:此注解是 @Component 的一种特化,用于表示某个类是仓库组件,并且应由 Spring 容器管理。 9. @Controller:此注解是 @Component 的一种特化,用于表示某个类是控制器组件,并且应由 Spring 容器管理。 10. @RequestParam:此注解用于将请求参数绑定到 Spring 应用程序中的方法参数。此注解可用于定义必需参数、默认值以及该参数是否为必填。 11. @PathParam:此注解用于将 URL 路径参数绑定到 Spring 应用程序中的方法参数。此注解可用于定义必需参数以及它是否为必填。 12. @SpringBootTest:此注解用于对 Spring Boot 应用程序执行集成测试。此注解可用于测试整个应用程序上下文,包括控制器、服务和仓库。它可用于验证应用程序整体的行为,并确保所有组件都正常工作。

These are just a few examples of the annotations that Spring Boot offers, and it provides many more which can be used for different purposes, like security, transactions, and so on. Using these annotations makes it easier to configure a Spring application, and Spring Boot also provides several sensible defaults that allow you to get started quickly without having to configure everything manually.

这些只是 Spring Boot 提供的注解中的几个例子,它还提供了更多可用于不同目的的注解,例如安全性、事务等。使用这些注解可以更容易地配置 Spring 应用程序,而且 Spring Boot 还提供了若干合理的默认值,使你无需手动配置所有内容就能快速开始。

128. Write a program to create and insert a new node in a binary tree in a level order manner

编写一个程序,以层序方式在二叉树中创建并插入一个新节点
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, delhivery, company-specific)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: general
  • 公司: Delhivery
  • id: 69b37a6e58d557c902ba692d | 官方: 否 | 付费: 否

答案:

The figure shows how you can insert a node in a level order manner.

该图展示了如何以层序方式插入节点。

Algorithm: - For traversing in a level order manner, a queue is required because a queue follows FIFO i.e. first in first out.

算法:- 为了以层序方式遍历,需要一个队列,因为队列遵循先进先出(FIFO)原则。
  • For inserting a node, first, check whether the root node is not or not. In the base case. If the root is NULL, then create a new node and return it.
  • Now traverse the tree in a level order manner using a queue and find the first empty space for inserting the new node.
  • If the left child of the node is NULL then insert the new node to the left, else check for the right child.
  • If the left or right child is not NULL, then insert their children into the queue and traverse until the queue becomes empty.
    Implementation:

    实现:

include

include

using namespace std;

using namespace std;

struct Node {

struct Node {
int val;
int val;
Node* lval;
Node* lval;
Node* rval;
Node* rval;
};

//Function to create a new node

//函数用于创建一个新节点
Node* newNode(int val)
Node* newNode(int val)
{
Node* n = new Node();
Node* n = new Node();
if (!n) {
if (!n) {
cout << "Memory error\n";
cout << "内存错误\n";
return NULL;
return NULL;
}
n->val = val;
n->val = val;
n->lval = n->rval = NULL;
n->lval = n->rval = NULL;
return n;
返回 n;
}

//Function to insert the given node

//用于插入给定节点的函数
Node Insert(Node root, int val)
Node Insert(Node root, int val)
{

if (root == NULL) {

if (root == NULL) {
root = newNode(val);
root = newNode(val);
return root;
return root;
}

queue<Node*> que;

queue<Node*> que;
que.push(root);
que.push(root);

while (!que.empty()) {

while (!que.empty()) {
Node* x = que.front();
Node* x = que.front();
que.pop();
que.pop();

if (x->lval != NULL)

if (x->lval != NULL)
que.push(x->lval);
que.push(x->lval);
else {
否则 {
x->lval = newNode(val);
x->lval = newNode(val);
return root;
return root;
}

if (x->rval != NULL)

if (x->rval != NULL)
que.push(x->rval);
que.push(x->rval);
else {
否则 {
x->rval = newNode(val);
x->rval = newNode(val);
return root;
return root;
}
}
}
//Inorder traversal of a BT
//二叉树的中序遍历
void inorder(Node* x)
void inorder(Node* x)
{
if (x == NULL)
if (x == NULL)
return;
return;

inorder(x->lval);

inorder(x->lval);
cout << x->val << ' ';
cout << x->val << ' ';
inorder(x->rval);
inorder(x->rval);
}

int main()

int main()
{
Node* root = newNode(5);
Node* root = newNode(5);
root->lval = newNode(1);
root->lval = newNode(1);
root->lval->lval = newNode(7);
root->lval->lval = newNode(7);
root->rval = newNode(9);
root->rval = newNode(9);
root->rval->lval = newNode(16);
root->rval->lval = newNode(16);
root->rval->rval = newNode(10);
root->rval->rval = newNode(10);

cout << " Before insertion: ";

cout << " Before insertion: ";
inorder(root);
inorder(root);
cout << endl;
cout << endl;
int add = 11;
int add = 11;
root = Insert(root, add);
root = Insert(root, add);

cout << "After insertion: ";

cout << "After insertion: ";
inorder(root);
inorder(root);
cout << endl;
cout << endl;

return 0;

return 0;
}
Time and space analysis: - Time Complexity: O(N), where N is the number of nodes in the given binary tree
时间与空间分析:- 时间复杂度:O(N),其中 N 为给定二叉树中的节点数
  • Space Complexity: O(1)

129. What are Django URLs?

Django URLs 是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba7291 | 官方: 否 | 付费: 否

答案:

URLs are one of the most important parts of a web application and Django provides you with an elegant way to design your own custom URLs with help of its module known as URLconf (URL Configuration). The basic functionality of this python module is to You can design your own URLs in Django in the way you like and then map them to the python function (View function). These URLs can be static as well as dynamic. These URLs as present in the urls.py where they are matched with the equivalent view function.

URLs 是 Web 应用程序最重要的部分之一,Django 通过其名为 URLconf(URL 配置)的模块,为您提供了一种优雅的方式来设计自定义 URLs。这个 python 模块的基本功能是,您可以在 Django 中按自己喜欢的方式设计 URLs,然后将它们映射到 python 函数(视图函数)。这些 URLs 既可以是静态的,也可以是动态的。这些 URLs 位于 urls.py 中,它们在那里与相应的视图函数进行匹配。

Basic Syntax:

基本语法:

from django.urls import path

from django.urls import path
from . import views
from . import views
urlpatterns = [
urlpatterns = [
path('data/2020/', views.data_2020),
path('data/2020/', views.data_2020),
path('data/<int:year>/', views.data_year)
path('data/<int:year>/', views.data_year)
]

130. Explain the django project directory structure?

解释一下Django项目目录结构?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba7297 | 官方: 否 | 付费: 否

答案:

  • manage.py - A command-line utility that allows you to interact with your Django project
  • __init__.py - An empty file that tells Python that the current directory should be considered as a Python package
  • settings.py - Comprises the configurations of the current project like DB connections.
  • urls.py - All the URLs of the project are present here
  • wsgi.py - This is an entry point for your application which is used by the web servers to serve the project you have created.

131. What are models in Django?

Django中的模型是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba729a | 官方: 否 | 付费: 否

答案:

A model in Django refers to a class that maps to a database table or database collection. Each attribute of the Django model class represents a database field. They are defined in app/models.py

Django中的模型指的是映射到数据库表或数据库集合的类。Django模型类的每个属性代表一个数据库字段。它们定义在app/models.py中。

Example:

示例:

from django.db import models

from django.db import models
class SampleModel(models.Model):
class SampleModel(models.Model):
field1 = models.CharField(max_length = 50)
field1 = models.CharField(max_length = 50)
field2 = models.IntegerField()
field2 = models.IntegerField()
class Meta:
class Meta:
db_table = “sample_model”
db_table = “sample_model”
Every model inherits from django.db.models.Model Our example has 2 attributes (1 char and 1 integer field), those will be in the table fields.
每个模型继承自django.db.models.Model,我们的示例有2个属性(1个字符字段和1个整数字段),这些将作为表字段。

The metaclass helps you set things like available permissions, singular and plural versions of the name, associated database table name, whether the model is abstract or not, etc. To get more information about models you can refer here: https://docs.djangoproject.com/en/3.1/topics/db/models/ .

元类帮助您设置可用权限、名称的单数和复数版本、关联的数据库表名、模型是否为抽象模型等。要获取更多关于模型的信息,可以参考这里:https://docs.djangoproject.com/en/3.1/topics/db/models/ 。

132. What are templates in Django or Django template language?

Django中的模板是什么,或者说Django模板语言是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba729d | 官方: 否 | 付费: 否

答案:

Templates are an integral part of the Django MVT architecture. They generally comprise HTML, CSS, and js in which dynamic variables and information are embedded with the help of views. Some constructs are recognized and interpreted by the template engine. The main ones are variables and tags.

模板是Django MVT架构中不可或缺的一部分。它们通常包含HTML、CSS和JS,动态变量和信息在视图的帮助下嵌入其中。一些结构会被模板引擎识别和解释,主要包括变量和标签。

A template is rendered with a context. Rendering just replaces variables with their values, present in the context, and processes tags. Everything else remains as it is.

模板使用上下文进行渲染。渲染过程只是将上下文中的变量替换为其值,并处理标签,其他内容保持不变。

The syntax of the Django template language includes the following four constructs : - Variables

Django模板语言的语法包括以下四种结构:- 变量

133. What are views in Django?

Django中的视图是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72a0 | 官方: 否 | 付费: 否

答案:

A view function, or “view” for short, is simply a Python function that takes a web request and returns a web response. This response can be HTML contents of a web page, or a redirect, or a 404 error, or an XML document, or an image, etc.

视图函数,或简称为“视图”,本质上是一个Python函数,它接收一个网络请求并返回一个网络响应。这个响应可以是网页的HTML内容、重定向、404错误、XML文档或图像等。

Example:

示例:

from django.http import HttpResponse

from django.http import HttpResponse
def sample_function(request):
def sample_function(request):
return HttpResponse(“Welcome to Django”)
return HttpResponse(“Welcome to Django”)
There are two types of views: - Function-Based Views: In this, we import our view as a function.
视图有两种类型:- 基于函数的视图:在这种方式中,我们将视图作为函数导入。
  • Class-based Views: It’s an object-oriented approach.

134. What is Django ORM?

什么是Django ORM?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72a3 | 官方: 否 | 付费: 否

答案:

This ORM (an acronym for Object Relational Mapper) enables us to interact with databases in a more pythonic way like we can avoid writing raw queries, it is possible to retrieve, save, delete and perform other operations over the database without ever writing any SQL query. It works as an abstraction layer between the models and the database.

这个ORM(Object Relational Mapper的缩写,即对象关系映射器)使我们能够以更Python化的方式与数据库交互,比如可以避免编写原始查询,无需编写任何SQL查询即可对数据库执行检索、保存、删除和其他操作。它充当模型和数据库之间的抽象层。

135. Define static files and explain their uses?

定义静态文件并解释它们的用途?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72a6 | 官方: 否 | 付费: 否

答案:

Websites generally need to serve additional files such as images. Javascript or CSS. In Django, these files are referred to as “static files”, Apart from that Django provides django.contrib.staticfiles to manage these static files.

网站通常需要提供额外的文件,如图像、JavaScript或CSS。在Django中,这些文件被称为“静态文件”。此外,Django提供了django.contrib.staticfiles来管理这些静态文件。

136. What is Django Rest Framework(DRF)?

什么是Django Rest Framework(DRF)?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72a9 | 官方: 否 | 付费: 否

答案:

Django Rest Framework is an open-source framework based upon Django which lets you create RESTful APIs rapidly.

Django Rest Framework 是一个基于 Django 的开源框架,可让你快速创建 RESTful API。

137. What is django-admin and manage.py and explain its commands?

什么是 django-admin 和 manage.py,并解释其命令?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72ac | 官方: 否 | 付费: 否

答案:

django-admin is Django’s command-line utility for administrative tasks. In addition to this, a manage.py file is also automatically created in each Django project. Not only does it perform the same purpose as the django-admin but it also sets the DJANGO_SETTINGS_MODULE environment variable to point to the project's settings.py file. - django-admin help - used to display usage information and a list of the commands provided by each application.

django-admin 是 Django 用于管理任务的命令行工具。此外,每个 Django 项目中也会自动创建一个 manage.py 文件。它不仅执行与 django-admin 相同的功能,还设置 DJANGO_SETTINGS_MODULE 环境变量以指向项目的 settings.py 文件。- django-admin help - 用于显示使用信息以及每个应用提供的命令列表。
  • django-admin version - used to check your Django version.
  • django-admin check - used to inspect the entire Django project for common problems.
  • django-admin compilemessages - Compiles .po files created by makemessages to .mo files for use with the help of built-in gettext support.
  • django-admin createcachetable - Creates the cache tables for use in the database cache backend.
  • django-admin dbshell - Runs the command-line client for the database engine specified in your ENGINE setting(s), with the connection parameters (USER, PASSWORD, DB_NAME, USER etc.) specified settings file.
  • django-admin diffsettings - Shows the difference between the existing settings file and Django’s default settings.
  • django-admin dumpdata - Used to the dumpdata from the database.
  • django-admin flush - Flush all values from the database and also re-executes any post-synchronization handlers specified in the code.
  • django-admin inspectdb - It generates django models from the existing database tables.
  • django-admin loaddata - loads the data into the database from the fixture file.
  • django-admin makemessages - Used for translation purpose and it generates a message file too.
  • django-admin makemigrations - Generates new migrations as per the changes detected to your models.
  • django-admin migrate - Executes SQL commands after which the database state with the current set of models and migrations are synchronized.
  • django-admin runserver - Starts a light-weight Web server on the local machine for development. The default server runs on port 8000 on the IP address 127.0.0.1. You can pass a custom IP address and port number explicitly if you want.
  • django-admin sendtestemail - This is used to confirm email sending through Django is working by sending a test email to the recipient(s) specified.
  • django-admin shell - Starts the Python interactive interpreter.
  • django-admin showmigrations - Shows all migrations present in the project.
  • django-admin sqlflush - Prints the SQL statements that would be executed for the flush command mentioned above.
  • django-admin sqlmigrate - Prints the SQL statement for the named migration.
  • django-admin sqlsequencereset - output the SQL queries for resetting sequences for the given app name(s).
  • django-admin squashmigrations - Squashes a range of migrations for a particular app_label.
  • django-admin startapp - Creates a new Django app for the given app name within the current directory or at the given destination.
  • django-admin startproject - Creates a new Django project directory structure for the given project name within the current directory or at the given destination.
  • django-admin test - Runs tests for all installed apps.
  • django-admin testserver - Runs a Django development server (which is also executed via the runserver command) using data from the given fixture(s).
  • django-admin changepassword - offers a method to change the user's password.
  • django-admin createsuperuser - Creates a user account with all permissions(also known as superuser account).
  • django-admin remove_stale_contenttypes - removes stale content types (from deleted models) in your database.
  • django-admin clearsessions - Can be used to clean out expired sessions or as a cron job.

138. What is Jinja templating?

什么是 Jinja 模板?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72af | 官方: 否 | 付费: 否

答案:

Jinja Templating is a very popular templating engine for Python, the latest version is Jinja2.

Jinja 模板是 Python 中非常流行的模板引擎,最新版本是 Jinja2。

Some of its features are: - Sandbox Execution - This is a sandbox (or a protected) framework for automating the testing process

它的一些特性包括:- 沙箱执行 - 这是一个用于自动化测试过程的沙箱(或受保护)框架
  • HTML Escaping - It provides automatic HTML Escaping as , & characters have special values in templates and if using a regular text, these symbols can lead to XSS Attacks which Jinja deals with automatically.
  • Template Inheritance
  • Generates HTML templates much faster than default engine
  • Easier to debug as compared to the default engine.

139. Explain Django Architecture?

解释 Django 架构?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72b2 | 官方: 否 | 付费: 否

答案:

Django follows the MVT (Model View Template) pattern which is based on the Model View Controller architecture. It’s slightly different from the MVC pattern as it maintains its own conventions, so, the controller is handled by the framework itself. The template is a presentation layer. It is an HTML file mixed with Django Template Language (DTL). The developer provides the model, the view, and the template then maps it to a URL, and finally, Django serves it to the user.

Django 遵循 MVT(模型视图模板)模式,该模式基于模型视图控制器架构。它与 MVC 模式略有不同,因为它维护自己的约定,因此控制器由框架本身处理。模板是表示层。它是混合了 Django 模板语言(DTL)的 HTML 文件。开发者提供模型、视图和模板,然后将其映射到 URL,最后 Django 将其提供给用户。

140. What is the difference between a project and an app in Django?

在 Django 中,项目和应用之间有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72b5 | 官方: 否 | 付费: 否

答案:

In simple words Project is the entire Django application and an app is a module inside the project that deals with one specific use case. For eg, payment system(app) in the eCommerce app(Project).

简单来说,项目是整个 Django 应用程序,而应用是项目中处理特定用例的模块。例如,电子商务应用(项目)中的支付系统(应用)。

141. What are different model inheritance styles in the Django?

Django 中有哪些不同的模型继承风格?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72b8 | 官方: 否 | 付费: 否

答案:

  • Abstract Base Class Inheritance: Used when you only need the parent class to hold information that you don’t want to write for each child model.
  • Multi-Table Model Inheritance: Used when you are subclassing an existing model and need each model to have its own table in the database.
  • Proxy Model Inheritance: Used when you want to retain the model's field while altering the python level functioning of the model.

142. 解释 RESTful API(Application Programming Interface)设计的最佳实践,以及在GitLab CI/CD(GitLab CI/CD)中如何应用。

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: gitlab, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: GitLab
  • id: 69b37b0858d557c902bac650 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

143. Find that Is there a loop in a linked list? Given the head of the list and determine if it loops back to itself. A linked list has a loop if there is some node that can be reached again by following the next pointer in consecutive nodes.

判断链表中是否存在环?给定链表的头节点,并判断它是否会回环到自身。如果存在某个节点,通过沿连续节点的 next 指针可以再次到达,则该链表存在环。
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, hashedin, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: HashedIn
  • id: 69b37b2f58d557c902badb92 | 官方: 否 | 付费: 否

答案:

Explanation:

说明:

In the above figure you can see that the last node connected with node 2. Here the Cycle exists. So we need to return true, which means the list contains a loop.

在上图中可以看到,最后一个节点与节点 2 相连。这里存在环。因此我们需要返回 true,这意味着该链表包含环。

Solution:

解决方案:
Although there can be many solutions to this problem, one is to start with every node and check if we are reaching the same node again. But this is not a very optimal solution. Another solution is to start traversing the list and keep track of every node in the HashMap while traversing and check if that node is already present in the HashMap. If the node is already present then that means there is a cycle, so we need to return true. This solution is optimal in terms of time, but it consumes extra space. So for avoiding space complexity, we can use the two-pointer approach of slow and fast pointers and check that if both slow and fast pointers reach the same node, then that means the list contains a cycle. So let’s implement this algorithm.
尽管这个问题有多种解决方案,其中一种是从每个节点开始并检查是否再次到达同一节点。但这不是最优解。另一种解决方案是开始遍历列表并在遍历时在HashMap中记录每个节点,并检查该节点是否已存在于HashMap中。如果节点已存在,则意味着存在循环,因此我们需要返回true。这个解决方案在时间上是最优的,但它消耗额外空间。因此,为了避免空间复杂度,我们可以使用慢指针和快指针的双指针方法,并检查如果慢指针和快指针都到达同一节点,则意味着列表包含循环。那么让我们实现这个算法。

public boolean hasCycle(ListNode head) {

public boolean hasCycle(ListNode head) {
//Edge case
//边界情况
if(head == null || head.next == null)
if(head == null || head.next == null)
return false;
返回 false;

ListNode slow = head, fast = head;

ListNode slow = head, fast = head;

//Fast moves 2 steps and slow moves 1 step. If there is a cycle then both pointers will meet and that means the cycle exists in the list.

//快指针移动2步,慢指针移动1步。如果存在循环,则两个指针将相遇,这意味着列表中存在的循环。
while(fast != null && fast.next != null){
while(fast != null && fast.next != null){
fast = fast.next.next;
fast = fast.next.next;
slow = slow.next;
slow = slow.next;
if(slow == fast)
if(slow == fast)
return true;
返回 true;
}
//No cycle found so return false
//未发现循环,因此返回false
return false;
返回 false;
}
The above algorithm takes O(n) time because all the nodes travel only once. But if there is a cycle then the nodes will be visited only for some constant time. And constant O(1) space because no extra memory is required to detect the loop.
上述算法的时间复杂度为O(n),因为所有节点只遍历一次。但如果存在循环,则节点只会被访问常数次。空间复杂度为常数O(1),因为检测循环不需要额外内存。

144. Suppose you are given a binary tree and a target sum. Is there a root-to-leaf path where the sum of the values along the path is equal to the target sum? If so, return true; otherwise, return false. A leaf is a node that has no children.

假设给定一棵二叉树和一个目标和。是否存在一条从根到叶子的路径,使得路径上所有值的和等于目标和?如果存在,返回 true;否则,返回 false。叶子节点是指没有子节点的节点。
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, hashedin, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: HashedIn
  • id: 69b37b2f58d557c902badb95 | 官方: 否 | 付费: 否

答案:

For example - Consider the below tree and target = 26. And we can see the path exists in the tree from 9 -> 7 -> 6 -> 4. This path to 26. So we need to return true.

例如——考虑下面的树,目标 = 26。我们可以看到树中存在从 9 -> 7 -> 6 -> 4 的路径。这条路径之和为 26。所以我们需要返回 true。

Solution - For the solution, we can traverse the one sub-tree using DFS. And once we found that we reached the leaf node and found the sum equal to the target node then we can return true. Otherwise, we need to traverse the other sub-tree for finding the target and leaf node.

解决方案——对于该解决方案,我们可以使用 DFS 遍历其中一棵子树。一旦我们发现到达了叶子节点,并且发现和等于目标节点,那么我们可以返回 true。否则,我们需要遍历另一棵子树来寻找目标和叶子节点。

//The method returns the boolean result if there is a path.

//该方法返回是否存在路径的布尔结果。
public boolean solution(TreeNode root, int targetSum){
public boolean solution(TreeNode root, int targetSum){
//Base case when we reach to the leaf node and reached the target sum
//基本情况:当我们到达叶子节点且达到了目标和
if(root.left == null && root.right == null){
if(root.left == null && root.right == null){
if(targetSum-root.val == 0)
if(targetSum-root.val == 0)
return true;
返回 true;
return false;
返回 false;
}
boolean left = false;
boolean left = false;
//Search on the left sub-tree for the path.
//在左子树中搜索路径。
if(root.left != null){
if(root.left != null){
left = solution(root.left, targetSum-root.val);
left = solution(root.left, targetSum-root.val);
}
//Searching on the right sub-tree if there is no path in left sub-tree
//如果在左子树中没有找到路径,则在右子树中搜索
if(!left){
if(!left){
if(root.right != null)
if(root.right != null)
return solution(root.right, targetSum-root.val);
return solution(root.right, targetSum-root.val);
}
return left;
return left;
}
In the above approach, every node in the worst case will be traversed. So the time complexity will be O(n) . And we are using recursion, so the space complexity will be also O(n) in the worst case.
在上述方法中,最坏情况下每个节点都会被遍历。因此时间复杂度为O(n)。而且我们使用了递归,所以最坏情况下空间复杂度也是O(n)。

There are also many coding questions that are asked in HashedIn Interview. But the patterns that are followed are basically covered in the above questions.

HashedIn面试中还会问许多编码问题。但所遵循的模式基本上都包含在上述问题中。

HashedIn follows the same round for the senior roles. And also the levels of questions are almost similar. The rounds that differentiate the Interview rounds for the senior job profile are the proficiency and experience in development. General Questions related to the java expertise and some popular frameworks are asked. Like Java 8 concepts, Spring boot, Hibernate, Kafka, HLD design of the current project, LLD of e-commerce website, etc.

HashedIn对高级职位采用相同的面试轮次。问题的难度也几乎相似。区分高级职位面试轮次的是开发方面的熟练度和经验。会问到与Java专业知识及一些流行框架相关的一般性问题。例如Java 8概念、Spring Boot、Hibernate、Kafka、当前项目的HLD设计、电商网站的LLD等。

145. What Is Spring Boot Architecture?

什么是Spring Boot架构?
  • 知识点: 后端 / 系统设计/架构 (标签: interviewbit, hashedin, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: HashedIn
  • id: 69b37b2f58d557c902badb98 | 官方: 否 | 付费: 否

答案:

If you already know about Spring architecture, then you’ll be happy to know that Spring Boot architecture is built on top of the original architecture. It’s designed to address common problems related to scalability and speed. A Spring Boot application is a collection of several Java classes that work together to perform a specific task. Ideally, there should be three types of classes in your application - services, controllers, and repositories. Services are responsible for storing data, retrieving data from APIs, or sending data to APIs. Controllers receive data from services and save them as models so they can be returned to the user. Repositories are responsible for storing and retrieving data from a database. Although the application architecture might vary from project to project, there are a few things that should always remain the same. These include things like where you save your files, what programming language you use, and how the files are organized.

如果你已经了解Spring架构,那么你会高兴地知道Spring Boot架构是建立在原始架构之上的。它旨在解决与可扩展性和速度相关的常见问题。Spring Boot应用程序是由多个协同工作的Java类组成的集合,用于执行特定任务。理想情况下,你的应用程序中应有三类类——服务类、控制器类和仓库类。服务类负责存储数据、从API检索数据或向API发送数据。控制器类从服务类接收数据并将其保存为模型,以便返回给用户。仓库类负责从数据库存储和检索数据。虽然应用程序架构可能因项目而异,但有一些事情应始终保持不变。这些包括文件保存位置、使用的编程语言以及文件的组织方式。

146. 解释 RESTful API(Application Programming Interface)设计的最佳实践,以及在HubSpot CRM(HubSpot CRM)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: hubspot, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: HubSpot
  • id: 69b37b5158d557c902baefe4 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

147. 解释 RESTful API(RESTful Application Programming Interface)设计的最佳实践(Best Practices),以及在Instacart Marketplace中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: instacart, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Instacart
  • id: 69b37b6158d557c902baf876 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

148. What does it mean if a replica is not an In-Sync Replica for a long time?

如果副本长时间不是同步副本,这意味着什么?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8158d557c902bb1465 | 官方: 否 | 付费: 否

答案:

A replica that has been out of ISR for a long period of time indicates that the follower is unable to fetch data at the same rate as the leader.

副本长时间不在 ISR 中,表明从节点无法以与主节点相同的速率获取数据。

149. What are the traditional methods of message transfer? How is Kafka better from them?

传统的消息传递方法有哪些?Kafka 相比它们有何优势?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8158d557c902bb1468 | 官方: 否 | 付费: 否

答案:

Following are the traditional methods of message transfer:- - Message Queuing:- A point-to-point technique is used in the message queuing pattern. A message in the queue will be destroyed once it has been consumed, similar to how a message is removed from the server once it has been delivered in the Post Office Protocol. Asynchronous messaging is possible with these queues.If a network problem delays a message's delivery, such as if a consumer is unavailable, the message will be held in the queue until it can be sent. This means that messages aren't always sent in the same order. Instead, they are given on a first-come, first-served basis, which can improve efficiency in some situations.

以下是传统的消息传递方法:- - 消息队列:消息队列模式使用点对点技术。队列中的消息一旦被消费就会被销毁,类似于邮件在邮局协议中一旦被投递就会从服务器中删除。这些队列支持异步消息传递。如果网络问题延迟消息传递,例如消费者不可用,消息将保留在队列中直到可以发送。这意味着消息并不总是按相同顺序发送。相反,它们按先到先服务的原则提供,这在某些情况下可以提高效率。
  • Publisher - Subscriber Model:- The publish-subscribe pattern entails publishers producing ("publishing") messages in multiple categories and subscribers consuming published messages from the various categories to which they are subscribed. Unlike point-to-point texting, a message is only removed once it has been consumed by all category subscribers.Kafka caters to a single consumer abstraction that encompasses both of the aforementioned- the consumer group. Following are the benefits of using Kafka over the traditional messaging transfer techniques:
    Scalable: A cluster of devices is used to partition and streamline the data thereby, scaling up the storage capacity.

    可扩展性:使用设备集群来分区和简化数据,从而扩展存储容量。

Faster: Thousands of clients can be served by a single Kafka broker as it can manage megabytes of reads and writes per second.

更快:单个Kafka代理可以每秒处理兆字节的读写,从而服务于数千个客户端。

Durability and Fault-Tolerant: The data is kept persistent and tolerant to any hardware failures by copying the data in the clusters.

持久性和容错性:通过将数据复制到集群中,数据保持持久化并能容忍任何硬件故障。

150. What are the major components of Kafka?

Kafka的主要组件有哪些?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8158d557c902bb146b | 官方: 否 | 付费: 否

答案:

Following are the major components of Kafka:-

以下是Kafka的主要组件:-
  • Topic:
    A Topic is a category or feed in which records are saved and published.

    主题是保存和发布记录的类别或数据流。
    Topics are used to organize all of Kafka's records. Consumer apps read data from topics, whereas producer applications write data to them. Records published to the cluster remain in the cluster for the duration of a configurable retention period.
    主题用于组织Kafka的所有记录。消费者应用程序从主题读取数据,而生产者应用程序向其写入数据。发布到集群的记录会在集群中保留可配置的保留期。
    Kafka keeps records in the log, and it's up to the consumers to keep track of where they are in the log (the "offset"). As messages are read, a consumer typically advances the offset in a linear fashion. The consumer, on the other hand, is in charge of the position, as he or she can consume messages in any order. When reprocessing records, for example, a consumer can reset to an older offset.
    Kafka将记录保存在日志中,由消费者跟踪它们在日志中的位置(“偏移量”)。随着消息被读取,消费者通常以线性方式推进偏移量。然而,消费者负责位置,因为他或她可以按任何顺序消费消息。例如,在重新处理记录时,消费者可以重置到较旧的偏移量。
  • Producer:A Kafka producer is a data source for one or more Kafka topics that optimizes, writes, and publishes messages. Partitioning allows Kafka producers to serialize, compress, and load balance data among brokers.
  • Consumer:Data is read by consumers by reading messages from topics to which they have subscribed. Consumers will be divided into groups. Each consumer in a consumer group will be responsible for reading a subset of the partitions of each subject to which they have subscribed.
  • Broker:
    A Kafka broker is a server that works as part of a Kafka cluster (in other words, a Kafka cluster is made up of a number of brokers). Multiple brokers typically work together to build a Kafka cluster, which provides load balancing, reliable redundancy, and failover. The cluster is managed and coordinated by brokers using Apache ZooKeeper. Without sacrificing performance, each broker instance can handle read and write volumes of hundreds of thousands per second (and gigabytes of messages). Each broker has its own ID and can be in charge of one or more topic log divisions.

    Kafka代理是作为Kafka集群一部分工作的服务器(换句话说,Kafka集群由多个代理组成)。多个代理通常协作构建Kafka集群,提供负载均衡、可靠冗余和故障转移。集群由代理使用Apache ZooKeeper进行管理和协调。在不牺牲性能的情况下,每个代理实例可以每秒处理数十万次读写(以及千兆字节的消息)。每个代理有自己的ID,并可以负责一个或多个主题日志分区。
    ZooKeeper is also used by Kafka brokers for leader elections, in which a broker is chosen to lead the handling of client requests for a certain partition of a topic. Connecting to any broker will bring a client up to speed with the entire Kafka cluster. A minimum of three brokers should be used to achieve reliable failover; the higher the number of brokers, the more reliable the failover.
    ZooKeeper也被Kafka代理用于领导者选举,其中选择一个代理来领导处理针对主题特定分区的客户端请求。连接到任何代理将使客户端跟上整个Kafka集群。至少应使用三个代理以实现可靠的故障转移;代理数量越多,故障转移越可靠。

151. Explain the four core API architecture that Kafka uses.

解释Kafka使用的四个核心API架构。
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37b8158d557c902bb146e | 官方: 否 | 付费: 否

答案:

Following are the four core APIs that Kafka uses:

以下是Kafka使用的四个核心API:
  • Producer API:The Producer API in Kafka allows an application to publish a stream of records to one or more Kafka topics.
  • Consumer API:An application can subscribe to one or more Kafka topics using the Kafka Consumer API. It also enables the application to process streams of records generated in relation to such topics.
  • Streams API:The Kafka Streams API allows an application to use a stream processing architecture to process data in Kafka. An application can use this API to take input streams from one or more topics, process them using streams operations, and generate output streams to transmit to one or more topics. The Streams API allows you to convert input streams into output streams in this manner.
  • Connect API:The Kafka Connector API connects Kafka topics to applications. This opens up possibilities for constructing and managing the operations of producers and consumers, as well as establishing reusable links between these solutions. A connector, for example, may capture all database updates and ensure that they are made available in a Kafka topic.

152. What do you mean by a Partition in Kafka?

在Kafka中,分区是什么意思?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8158d557c902bb1471 | 官方: 否 | 付费: 否

答案:

Kafka topics are separated into partitions, each of which contains records in a fixed order. A unique offset is assigned and attributed to each record in a partition. Multiple partition logs can be found in a single topic. This allows several users to read from the same topic at the same time. Topics can be parallelized via partitions, which split data into a single topic among numerous brokers.

Kafka主题被分成多个分区,每个分区包含固定顺序的记录。每个分区中的每条记录都被分配一个唯一的偏移量。单个主题中可以找到多个分区日志。这允许多个用户同时从同一主题读取。主题可以通过分区并行化,将数据在多个代理之间拆分到单个主题中。

Replication in Kafka is done at the partition level. A replica is the redundant element of a topic partition. Each partition often contains one or more replicas, which means that partitions contain messages that are duplicated across many Kafka brokers in the cluster.

Kafka中的复制在分区级别进行。副本是主题分区的冗余元素。每个分区通常包含一个或多个副本,这意味着分区包含在集群中的多个Kafka代理之间复制的消息。

One server serves as the leader of each partition (replica), while the others function as followers. The leader replica is in charge of all read-write requests for the partition, while the followers replicate the leader. If the lead server goes down, one of the followers takes over as the leader. To disperse the burden, we should aim for a good balance of leaders, with each broker leading an equal number of partitions.

一台服务器作为每个分区(副本)的领导者,而其他服务器作为追随者。领导者副本负责该分区的所有读写请求,而追随者复制领导者。如果领导者服务器宕机,其中一个追随者将接管成为领导者。为分散负担,我们应力求领导者的良好平衡,使每个代理领导相等数量的分区。

153. What do you mean by zookeeper in Kafka and what are its uses?

在Kafka中,ZooKeeper是什么意思,它有哪些用途?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1474 | 官方: 否 | 付费: 否

答案:

Apache ZooKeeper is a naming registry for distributed applications as well as a distributed, open-source configuration and synchronization service. It keeps track of the Kafka cluster nodes' status, as well as Kafka topics, partitions, and so on.

Apache ZooKeeper 是一个用于分布式应用程序的命名注册表,同时也是一个分布式、开源的配置和同步服务。它跟踪 Kafka 集群节点的状态,以及 Kafka 主题、分区等。

ZooKeeper is used by Kafka brokers to maintain and coordinate the Kafka cluster. When the topology of the Kafka cluster changes, such as when brokers and topics are added or removed, ZooKeeper notifies all nodes. When a new broker enters the cluster, for example, ZooKeeper notifies the cluster, as well as when a broker fails. ZooKeeper also allows brokers and topic partition pairs to elect leaders, allowing them to select which broker will be the leader for a given partition (and server read and write operations from producers and consumers), as well as which brokers contain clones of the same data. When the cluster of brokers receives a notification from ZooKeeper, they immediately begin to coordinate with one another and elect any new partition leaders that are required. This safeguards against the unexpected absence of a broker.

ZooKeeper 被 Kafka 代理用于维护和协调 Kafka 集群。当 Kafka 集群的拓扑结构发生变化时,例如添加或删除代理和主题时,ZooKeeper 会通知所有节点。例如,当一个新的代理进入集群时,ZooKeeper 会通知集群,同样在代理故障时也是如此。ZooKeeper 还允许代理和主题分区对选举领导者,从而选择哪个代理将成为给定分区的领导者(并处理来自生产者和消费者的读写操作),以及哪些代理包含相同数据的副本。当代理集群收到来自 ZooKeeper 的通知时,它们会立即开始相互协调,并选举任何所需的新分区领导者。这保护了集群免受代理意外缺失的影响。

154. Can we use Kafka without Zookeeper?

我们可以在不使用 ZooKeeper 的情况下使用 Kafka 吗?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1477 | 官方: 否 | 付费: 否

答案:

  • Kafka can now be used without ZooKeeper as of version 2.8. The release of Kafka 2.8.0 in April 2021 gave us all the opportunity to try it out without ZooKeeper. However, this version is not yet ready for production and lacks some key features.
  • In the previous versions, bypassing Zookeeper and connecting directly to the Kafka broker was not possible. This is because when the Zookeeper is down, it is unable to fulfill client requests.

155. Explain the concept of Leader and Follower in Kafka.

解释 Kafka 中 Leader 和 Follower 的概念。
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb147a | 官方: 否 | 付费: 否

答案:

In Kafka, each partition has one server that acts as a Leader and one or more servers that operate as Followers. The Leader is in charge of all read and writes requests for the partition, while the Followers are responsible for passively replicating the leader. In the case that the Leader fails, one of the Followers will assume leadership. The server's load is balanced as a result of this.

在 Kafka 中,每个分区都有一个作为 Leader 的服务器和一个或多个作为 Follower 的服务器。Leader 负责处理该分区的所有读写请求,而 Follower 则负责被动地复制 Leader。如果 Leader 发生故障,其中一个 Follower 将接任领导角色。这因此实现了服务器负载的均衡。

156. Why is Topic Replication important in Kafka? What do you mean by ISR in Kafka?

为什么在 Kafka 中主题复制很重要?在 Kafka 中,ISR 是什么意思?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb147d | 官方: 否 | 付费: 否

答案:

Topic replication is critical for constructing Kafka deployments that are both durable and highly available. When one broker fails, topic replicas on other brokers remain available to ensure that data is not lost and that the Kafka deployment is not disrupted. The replication factor specifies the number of copies of a topic that are kept across the Kafka cluster. It takes place at the partition level and is defined at the subject level. A replication factor of two, for example, will keep two copies of a topic for each partition.

主题复制对于构建既持久又高可用的 Kafka 部署至关重要。当一个代理发生故障时,其他代理上的主题副本仍然可用,以确保数据不会丢失,并且 Kafka 部署不会中断。复制因子指定了在 Kafka 集群中保留的主题副本数量。它发生在分区级别,并在主题级别定义。例如,复制因子为 2 将为每个分区保留两个主题副本。

Each partition has an elected leader, and other brokers store a copy that can be used if necessary. Logically, the replication factor cannot be more than the cluster's total number of brokers. An In-Sync Replica (ISR) is a replica that is up to date with the partition's leader.

每个分区都有一个选举出的 Leader,其他代理存储一个可以在必要时使用的副本。逻辑上,复制因子不能超过集群中代理的总数。同步副本(ISR)是指与分区 Leader 保持同步的副本。

157. What do you understand about a consumer group in Kafka?

你对 Kafka 中的消费者组有什么理解?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1480 | 官方: 否 | 付费: 否

答案:

A consumer group in Kafka is a collection of consumers who work together to ingest data from the same topic or range of topics. The name of an application is essentially represented by a consumer group. Consumers in Kafka often fall into one of several categories. The ‘-group' command must be used to consume messages from a consumer group.

Kafka 中的消费者组是一组消费者,他们协同工作以从相同主题或一系列主题中摄取数据。应用程序的名称本质上由消费者组来表示。Kafka 中的消费者通常分为几个类别。必须使用 ‘-group' 命令才能从消费者组中消费消息。

158. What is the maximum size of a message that Kafka can receive?

Kafka 可以接收的最大消息大小是多少?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1483 | 官方: 否 | 付费: 否

答案:

By default, the maximum size of a Kafka message is 1MB (megabyte). The broker settings allow you to modify the size. Kafka, on the other hand, is designed to handle 1KB messages as well.

默认情况下,Kafka 消息的最大大小是 1MB(兆字节)。代理设置允许你修改该大小。然而,Kafka 也被设计为能够处理 1KB 大小的消息。

159. What are some of the features of Kafka?

Kafka 的一些特性是什么?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1486 | 官方: 否 | 付费: 否

答案:

Following are the key features of Kafka:-

以下是 Kafka 的主要特性:-
  • Kafka is a messaging system built for high throughput and fault tolerance.
  • Kafka has a built-in patriation system known as a Topic.
  • Kafka Includes a replication feature as well.
  • Kafka provides a queue that can handle large amounts of data and move messages from one sender to another.
  • Kafka can also save the messages to storage and replicate them across the cluster.
  • For coordination and synchronization with other services, Kafka collaborates with Zookeeper.
  • Apache Spark is well supported by Kafka.

160. How do you start a Kafka server?

如何启动 Kafka 服务器?
  • 知识点: 后端 / 行为与软技能 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1489 | 官方: 否 | 付费: 否

答案:

Firstly, we extract Kafka once we have downloaded the most recent version. We must make sure that our local environment has Java 8+ installed in order to run Kafka.

首先,我们下载最新版本后解压 Kafka。为了运行 Kafka,我们必须确保本地环境已安装 Java 8+。

The following commands must be done in order to start the Kafka server and ensure that all services are started in the correct order: - Start the ZooKeeper service by doing the following:

必须按以下顺序执行命令才能启动 Kafka 服务器并确保所有服务按正确顺序启动:- 通过执行以下操作启动 ZooKeeper 服务:
$bin/zookeeper-server-start.sh config/zookeeper.properties - To start the Kafka broker service, open a new terminal and type the following commands:
$bin/zookeeper-server-start.sh config/zookeeper.properties - 要启动 Kafka 代理服务,请打开新终端并输入以下命令:
$ bin/kafka-server-start.sh config/server.properties

161. What do you mean by geo-replication in Kafka?

Kafka 中的地理复制是什么意思?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb148c | 官方: 否 | 付费: 否

答案:

Geo-Replication is a Kafka feature that allows messages in one cluster to be copied across many data centers or cloud regions. Geo-replication entails replicating all of the files and storing them throughout the globe if necessary. Geo-replication can be accomplished with Kafka's MirrorMaker Tool. Geo-replication is a technique for ensuring data backup.

地理复制是 Kafka 的一项功能,允许将一个集群中的消息复制到多个数据中心或云区域。地理复制包括复制所有文件并在必要时将它们存储在全球各地。可以使用 Kafka 的 MirrorMaker 工具实现地理复制。地理复制是一种确保数据备份的技术。

162. What are some of the disadvantages of Kafka?

Kafka 有哪些缺点?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb148f | 官方: 否 | 付费: 否

答案:

Following are the disadvantages of Kafka : - Kafka performance degrades if there is message tweaking. When the message does not need to be updated, Kafka works well.

以下是 Kafka 的缺点:- 如果消息被调整,Kafka 的性能会下降。当消息不需要更新时,Kafka 运行良好。
  • Wildcard topic selection is not supported by Kafka. It is necessary to match the exact topic name.
  • Brokers and consumers reduce Kafka's performance when dealing with huge messages by compressing and decompressing the messages. This has an impact on Kafka's throughput and performance.
  • Certain message paradigms, including point-to-point queues and request/reply, are not supported by Kafka.
  • Kafka does not have a complete set of monitoring tools.

163. Tell me about some of the real-world usages of Apache Kafka.

告诉我一些 Apache Kafka 在现实世界中的用途。
  • 知识点: 后端 / 行为与软技能 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1492 | 官方: 否 | 付费: 否

答案:

Following are some of the real-world usages of Apache Kafka:

以下是 Apache Kafka 在现实世界中的一些用途:
  • As a Message Broker: Due to its high throughput value, Kafka is capable of managing a huge amount of comparable types of messages or data. Kafka can be used as a publish-subscribe messaging system that allows data to be read and published in a convenient manner.
  • To Monitor operational data: Kafka can be used to keep track of metrics related to certain technologies, such as security logs.
  • Website activity tracking: Kafka can be used to check that data is transferred and received successfully by websites. Kafka can handle the massive amounts of data created by websites for each page and for the activities of users.
  • Data logging: Kafka's data replication between nodes functionality can be used to restore data on nodes that have failed. Kafka may also be used to collect data from a variety of logs and make it available to consumers.
  • Stream Processing with Kafka: Kafka may be used to handle streaming data, which is data that is read from one topic, processed, and then written to another. Users and applications will have access to a new topic containing the processed data.

164. What are the use cases of Kafka monitoring?

Kafka 监控的用例有哪些?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1495 | 官方: 否 | 付费: 否

答案:

Following are the use cases of Kafka monitoring : - Track System Resource Consumption: It can be used to keep track of system resources such as memory, CPU, and disk utilization over time.

以下是 Kafka 监控的用例:- 跟踪系统资源消耗:它可以用于随时间跟踪内存、CPU 和磁盘利用率等系统资源。
  • Monitor threads and JVM usage: Kafka relies on the Java garbage collector to free up memory, ensuring that it runs frequently thereby guaranteeing that the Kafka cluster is more active.
  • Keep an eye on the broker, controller, and replication statistics so that the statuses of partitions and replicas can be modified as needed.
  • Finding out which applications are causing excessive demand and identifying performance bottlenecks might help solve performance issues rapidly.

165. What do you mean by Kafka schema registry?

Kafka 模式注册表是什么意思?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb1498 | 官方: 否 | 付费: 否

答案:

A Schema Registry is present for both producers and consumers in a Kafka cluster, and it holds Avro schemas. For easy serialization and de-serialization, Avro schemas enable the configuration of compatibility parameters between producers and consumers. The Kafka Schema Registry is used to ensure that the schema used by the consumer and the schema used by the producer are identical. The producers just need to submit the schema ID and not the whole schema when using the Confluent schema registry in Kafka. The consumer looks up the matching schema in the Schema Registry using the schema ID.

在 Kafka 集群中,生产者和消费者都存在模式注册表,它保存 Avro 模式。为了便于序列化和反序列化,Avro 模式支持在生产者和消费者之间配置兼容性参数。Kafka 模式注册表用于确保消费者使用的模式与生产者使用的模式相同。当在 Kafka 中使用 Confluent 模式注册表时,生产者只需提交模式 ID,而不需要提交整个模式。消费者使用模式 ID 在模式注册表中查找匹配的模式。

166. What are the benefits of using clusters in Kafka?

在 Kafka 中使用集群有哪些好处?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb149b | 官方: 否 | 付费: 否

答案:

Kafka cluster is basically a group of multiple brokers. They are used to maintain load balance. Because Kafka brokers are stateless, they rely on Zookeeper to keep track of their cluster state. A single Kafka broker instance can manage hundreds of thousands of reads and writes per second, and each broker can handle TBs of messages without compromising performance. Zookeeper can be used to choose the Kafka broker leader. Thus having a cluster of Kafka brokers heavily increases the performance.

Kafka 集群基本上是由多个代理组成的组。它们用于维持负载平衡。由于 Kafka 代理是无状态的,它们依赖 Zookeeper 来跟踪其集群状态。单个 Kafka 代理实例每秒可以管理数十万次读写,每个代理可以处理 TB 级消息而不影响性能。可以使用 Zookeeper 来选择 Kafka 代理领导者。因此,拥有 Kafka 代理集群可以大大提高性能。

167. Describe partitioning key in Kafka.

描述 Kafka 中的分区键。
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb149e | 官方: 否 | 付费: 否

答案:

In Kafka terminology, messages are referred to as records. Each record has a key and a value, with the key being optional. For record partitioning, the record's key is used. There will be one or more partitions for each topic. Partitioning is a straightforward data structure. It's the append-only sequence of records, which is arranged chronologically by the time they were attached. Once a record is written to a partition, it is given an offset – a sequential id that reflects the record's position in the partition and uniquely identifies it inside it.

在 Kafka 术语中,消息被称为记录。每条记录都有键和值,键是可选的。记录的键用于记录分区。每个主题将有一个或多个分区。分区是一种简单的数据结构。它是记录的仅追加序列,按附加时间按时间顺序排列。一旦记录写入分区,它会被赋予一个偏移量——一个序列 ID,反映记录在分区中的位置并唯一标识它。

Partitioning is done using the record's key. By default, Kafka producer uses the record's key to determine which partition the record should be written to. The producer will always choose the same partition for two records with the same key.

分区是根据记录的键进行的。默认情况下,Kafka 生产者使用记录的键来确定记录应被写入哪个分区。对于具有相同键的两条记录,生产者始终会选择相同的分区。

This is important because we may have to deliver records to customers in the same order that they were made. You want these events to come in the order they were created when a consumer purchases an eBook from your webshop and subsequently cancels the transaction. If you receive a cancellation event before a buy event, the cancellation will be rejected as invalid (since the purchase has not yet been registered in the system), and the system will then record the purchase and send the product to the client (and lose you money). You might use a customer id as the key of these Kafka records to solve this problem and assure ordering. This will ensure that all of a customer's purchase events are grouped together in the same partition.

这很重要,因为我们必须按照记录生成的顺序将记录交付给客户。当消费者从您的网上商店购买电子书并随后取消交易时,您希望这些事件按创建顺序到达。如果您在购买事件之前收到取消事件,取消将被视为无效而被拒绝(因为购买尚未在系统中注册),然后系统将记录购买并向客户端发送产品(导致您亏损)。您可以使用客户 ID 作为这些 Kafka 记录的键来解决此问题并确保顺序。这将确保某个客户的所有购买事件都被分组到同一分区中。

168. What is the purpose of partitions in Kafka?

Kafka 中分区的用途是什么?
  • 知识点: 后端 (主题: kafka, streaming;标签: interviewbit, kafka, topic-specific, streaming)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8258d557c902bb14a1 | 官方: 否 | 付费: 否

答案:

Partitions allow a single topic to be partitioned across numerous servers from the perspective of the Kafka broker. This allows you to store more data in a single topic than a single server can. If you have three brokers and need to store 10TB of data in a topic, one option is to construct a topic with only one partition and store all 10TB on one broker. Another alternative is to build a three-partitioned topic and distribute 10 TB of data among all brokers. A partition is a unit of parallelism from the consumer's perspective.

从 Kafka 代理的角度来看,分区允许单个主题被划分到多个服务器上。这使您能够在一个主题中存储比单个服务器所能容纳的更多数据。如果您有三个代理且需要在主题中存储 10TB 数据,一个选项是构建只有一个分区的主题并将所有 10TB 数据存储在一个代理上。另一个选择是构建具有三个分区的主题,并在所有代理之间分布 10TB 的数据。从消费者的角度来看,分区是并行性的单位。

169. What are migrations in Laravel?

Laravel 中的迁移是什么?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb1591 | 官方: 否 | 付费: 否

答案:

In simple, Migrations are used to create database schemas in Laravel. In migration files, we store which table to create, update or delete.

简单来说,迁移用于在 Laravel 中创建数据库架构。在迁移文件中,我们存储要创建、更新或删除哪些表。

Each migration file is stored with its timestamp of creation to keep track of the order in which it was created. As migrations go up with your code in GitHub, GitLab, etc, whenever anyone clones your project they can run PHP artisan migrate to run those migrations to create the database in their environment. A normal migration file looks like below:

每个迁移文件都保存有其创建时的时间戳,以跟踪其创建顺序。随着迁移与您的代码一起上传到 GitHub、GitLab 等平台,每当有人克隆您的项目时,他们可以运行 PHP artisan migrate 来执行这些迁移,从而在其环境中创建数据库。一个普通的迁移文件如下所示:

<?php

<?php

use Illuminate\Database\Migrations\Migration;

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration

class CreateUsersTable extends Migration
{
/**
  • Run the migrations.

    • 运行迁移。
      *
  • @return void

    • @return void
      */
      public function up()
      public function up()
      {
      Schema::create('users', function (Blueprint $table) {
      Schema::create('users', function (Blueprint $table) {
      $table->id();
      $table->id();
      $table->string('name');
      $table->string('name');
      // Create other columns
      // 创建其他列
      });
      }

/**

  • Reverse the migrations.

    • 反向迁移。
      *
  • @return void

    • @return void
      */
      public function down()
      public function down()
      {
      Schema::dropIfExists('users');
      Schema::dropIfExists('users');
      }
      }
      The up() method runs when we run php artisan migrate and down() method runs when we run php artisan migrate:rollback.
      当我们运行 php artisan migrate 时,up() 方法会执行;当我们运行 php artisan migrate:rollback 时,down() 方法会执行。

If we rollback, it only rolls back the previously run migration.

如果回滚,它只会回滚之前运行的迁移。

If we want to rollback all migrations, we can run 'php artisan migrate:reset.

如果我们想回滚所有迁移,可以运行 'php artisan migrate:reset。

If we want to rollback and run migrations, we can run PHP artisan migrate:refresh, and we can use PHP artisan migrate:fresh` to drop the tables first and then run migrations from the start.

如果我们想回滚并重新运行迁移,可以运行 PHP artisan migrate:refresh,也可以使用 PHP artisan migrate:fresh` 先删除表,然后从头运行迁移。

170. What is the latest Laravel version?

最新的 Laravel 版本是什么?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb1594 | 官方: 否 | 付费: 否

答案:

The latest Laravel version is 8.x.

最新的 Laravel 版本是 8.x。

171. What are Models?

什么是模型?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb1597 | 官方: 否 | 付费: 否

答案:

With Laravel, each database table can have a model representation using a model file which can be used to interact with that table using Laravel Eloquent ORM.

使用 Laravel,每个数据库表都可以有一个模型文件来表示,该文件可以使用 Laravel Eloquent ORM 与该表进行交互。

We can create a model using this artisan command:

我们可以使用这个 artisan 命令创建模型:

php artisan make:model Post

php artisan make:model Post
This will create a file in the models’ directory and will look like below:
这将在模型目录中创建一个文件,内容如下所示:

class Post extends Model

class Post extends Model
{
/**
  • The attributes that are mass assignable.

    • 可批量赋值的属性。
      *
  • @var array

    • @var array
      */
      protected $fillable = [];
      protected $fillable = [];

/**

  • The attributes that should be hidden for arrays.

    • 在数组转换时应隐藏的属性。
      *
  • @var array

    • @var array
      */
      protected $hidden = [];
      protected $hidden = [];
      }
      A Model can have properties like table, fillable, hidden, etc which defines properties of the table and model.
      模型可以具有如table、fillable、hidden等属性,这些属性定义了表和模型的相关特性。

172. How to implement soft delete in Laravel?

如何在Laravel中实现软删除?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b37b8358d557c902bb159a | 官方: 否 | 付费: 否

答案:

Soft Delete means when any data row is deleted by any means in the database, we are not deleting the data but adding a timestamp of deletion.

软删除意味着当数据库中的任何数据行被以任何方式删除时,我们并非真正删除数据,而是添加一个删除时间戳。

We can add soft delete features by adding a trait in the model file like below.

我们可以通过在模型文件中添加一个trait来启用软删除功能,如下所示。

use Illuminate\Database\Eloquent\Model;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\SoftDeletes;

class Post extends Model {

class Post extends Model {

use SoftDeletes;

use SoftDeletes;

protected $table = 'posts';

protected $table = 'posts';

// ...
}

173. What are factories in Laravel?

什么是 Laravel 中的工厂(factories)?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb159d | 官方: 否 | 付费: 否

答案:

Factories are a way to put values in fields of a particular model automatically. Like, for testing when we add multiple fake records in the database, we can use factories to generate a class for each model and put data in fields accordingly. Every new laravel application comes with database/factories/UserFactory.php which looks like below:

工厂是一种自动将值填入特定模型字段的方式。例如,测试时向数据库中添加多条虚假记录,我们可以使用工厂为每个模型生成一个类,并相应地将数据填入字段中。每个新的 Laravel 应用都自带 database/factories/UserFactory.php 文件,内容如下所示:

<?php

<?php

namespace Database\Factories;

namespace Database\Factories;

use App\Models\User;

use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Illuminate\Support\Str;

class UserFactory extends Factory

class UserFactory extends Factory
{
/**
  • The name of the factory's corresponding model.

    • 工厂对应模型的名称。
      *
  • @var string

    • @var string
      */
      protected $model = User::class;
      protected $model = User::class;

/**

  • Define the model's default state.

    • 定义模型的默认状态。
      *
  • @return array

    • @return array
      */
      public function definition()
      public function definition()
      {
      return [
      return [
      'name' => $this->faker->name,
      'name' => $this->faker->name,
      'email' => $this->faker->unique()->safeEmail,
      'email' => $this->faker->unique()->safeEmail,
      'email_verified_at' => now(),
      'email_verified_at' => now(),
      'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
      'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // 密码
      'remember_token' => Str::random(10),
      'remember_token' => Str::random(10),
      ];
      }
      }
      We can create a new factory using php artisan make:factory UserFactory --class=User .
      我们可以使用 php artisan make:factory UserFactory --class=User 创建一个新的工厂。

The above command will create a new factory class for the User model. It is just a class that extends the base Factory class and makes use of the Faker class to generate fake data for each column. With the combination of factory and seeders, we can easily add fake data into the database for testing purposes.

上述命令将为 User 模型创建一个新的工厂类。它只是一个继承基础 Factory 类的类,并利用 Faker 类为每一列生成假数据。通过工厂和种子文件的组合,我们可以轻松地将假数据添加到数据库中,用于测试目的。

174. What are seeders in Laravel?

Laravel 中的种子文件是什么?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15a0 | 官方: 否 | 付费: 否

答案:

Seeders in Laravel are used to put data in the database tables automatically. After running migrations to create the tables, we can run php artisan db:seed to run the seeder to populate the database tables.

Laravel 中的种子文件用于自动将数据放入数据库表中。运行迁移创建表后,我们可以运行 php artisan db:seed 来执行种子文件,以填充数据库表。

We can create a new Seeder using the below artisan command:

我们可以使用下面的 artisan 命令创建一个新的种子文件:

php artisan make:seeder [className]

php artisan make:seeder [className]
It will create a new Seeder like below:
它将创建一个新的种子文件,如下所示:

<?php

<?php

use App\Models\Auth\User;

use App\Models\Auth\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Seeder;
use Illuminate\Database\Seeder;

class UserTableSeeder extends Seeder

class UserTableSeeder extends Seeder
{
/**
  • Run the database seeds.

    • 运行数据库种子。
      */
      public function run()
      public function run()
      {
      factory(User::class, 10)->create();
      factory(User::class, 10)->create();
      }
      }
      The run() method in the above code snippet will create 10 new users using the User factory.
      上述代码片段中的 run() 方法将使用 User 工厂创建 10 个新用户。

Factories will be explained in the next question.

工厂将在下一个问题中解释。

175. What are the default route files in Laravel?

Laravel 中的默认路由文件有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15a3 | 官方: 否 | 付费: 否

答案:

Below are the four default route files in the routes folder in Laravel: - web.php - For registering web routes.

以下是 Laravel 中 routes 文件夹内的四个默认路由文件:- web.php - 用于注册 web 路由。
  • api.php - For registering API routes.
  • console.php - For registering closure-based console commands.
  • channel.php - For registering all your event broadcasting channels that your application supports.

176. How to put Laravel applications in maintenance mode?

如何将 Laravel 应用程序置于维护模式?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15a6 | 官方: 否 | 付费: 否

答案:

Maintenance mode is used to put a maintenance page to customers and under the hood, we can do software updates, bug fixes, etc. Laravel applications can be put into maintenance mode using the below command:

维护模式用于向客户显示维护页面,在后台,我们可以进行软件更新、修复错误等操作。Laravel 应用程序可以使用以下命令进入维护模式:

php artisan down

php artisan down
And can put the application again on live using the below command:
并且可以使用以下命令再次将应用程序上线:

php artisan up

php artisan up
Also, it is possible to access the website in maintenance mode by whitelisting particular IPs.
此外,还可以通过白名单特定 IP 地址在维护模式下访问网站。

177. Can we use Laravel for Full Stack Development (Frontend + Backend)?

我们能否使用 Laravel 进行全栈开发(前端 + 后端)?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15a9 | 官方: 否 | 付费: 否

答案:

Laravel is the best choice to make progressive, scalable full-stack web applications. Full-stack web applications can have a backend in laravel and the frontend can be made using blade files or SPAs using Vue.js as it is provided by default. But it can also be used to just provide rest APIs to a SPA application.

Laravel 是构建渐进式、可扩展的全栈 Web 应用程序的最佳选择。全栈 Web 应用程序可以为后端使用 Laravel,前端可以使用 blade 文件或使用默认提供的 Vue.js 构建 SPA。但它也可以仅用于为 SPA 应用程序提供 REST API。

Hence, Laravel can be used to make full-stack applications or just the backend APIs only.

因此,Laravel 可用于构建全栈应用程序,或仅构建后端 API。

178. How to define environment variables in Laravel?

如何在 Laravel 中定义环境变量?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15ac | 官方: 否 | 付费: 否

答案:

The environment variables can be defined in the .env file in the project directory. A brand new laravel application comes with a .env.example and while installing we copy this file and rename it to .env and all the environment variables will be defined here.

环境变量可以在项目目录中的 .env 文件中定义。一个全新的 Laravel 应用程序自带一个 .env.example 文件,在安装过程中我们复制此文件并将其重命名为 .env,所有环境变量都将在此处定义。

Some of the examples of environment variables are APP_ENV, DB_HOST, DB_PORT, etc.

环境变量的一些示例包括 APP_ENV、DB_HOST、DB_PORT 等。

179. What is an artisan?

什么是 artisan?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15af | 官方: 否 | 付费: 否

答案:

Artisan is the command-line tool for Laravel to help the developer build the application. You can enter the below command to get all the available commands:

Artisan 是 Laravel 的命令行工具,帮助开发者构建应用程序。您可以输入以下命令获取所有可用的命令:

PHP artisan list: Artisan command can help in creating the files using the make command. Some of the useful make commands are listed below:

PHP artisan list:Artisan 命令可以使用 make 命令帮助创建文件。下面列出了一些有用的 make 命令:

php artisan make:controller - Make Controller file

php artisan make:controller - 创建控制器文件
php artisan make:model - Make a Model file
php artisan make:model - 创建模型文件
php artisan make:migration - Make Migration file
php artisan make:migration - 创建迁移文件
php artisan make:seeder - Make Seeder file
php artisan make:seeder - 创建种子文件
php artisan make:factory - Make Factory file
php artisan make:factory - 创建工厂文件
php artisan make:policy - Make Policy file
php artisan make:policy - 创建策略文件
php artisan make:command - Make a new artisan command
php artisan make:command - 创建新的 artisan 命令

180. What are available databases supported by Laravel?

Laravel 支持哪些可用的数据库?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15b5 | 官方: 否 | 付费: 否

答案:

The supported databases in laravel are: - PostgreSQL

Laravel 中支持的数据库有:- PostgreSQL
  • SQL Server
  • SQLite
  • MySQL

181. What is the templating engine used in Laravel?

Laravel 中使用的模板引擎是什么?
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15b9 | 官方: 否 | 付费: 否

答案:

The templating engine used in Laravel is Blade . The blade gives the ability to use its mustache-like syntax with the plain PHP and gets compiled into plain PHP and cached until any other change happens in the blade file. The blade file has .blade.php extension.

Laravel 中使用的模板引擎是 Blade。Blade 提供了使用其类似 mustache 的语法与纯 PHP 结合的能力,并编译为纯 PHP 并缓存,直到 blade 文件中发生任何其他更改。Blade 文件的扩展名为 .blade.php。

182. Define Composer.

定义 Composer。
  • 知识点: 后端 / 编程语言基础 (主题: laravel, php, backend;标签: interviewbit, laravel, topic-specific, php, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37b8358d557c902bb15bc | 官方: 否 | 付费: 否

答案:

Composer is the package manager for the framework. It helps in adding new packages from the huge community into your laravel application.

Composer 是该框架的包管理器。它有助于从庞大的社区中向你的 Laravel 应用添加新包。

For example, one of the most used packages for authentication will be Passport, for including that into your project, you can run the below command on your terminal:

例如,最常用的认证包之一是 Passport,要将其包含到你的项目中,可以在终端上运行以下命令:

composer requires laravel/passport

composer requires laravel/passport
It generates a file(composer.json) in your project directory to keep track of all your packages. A default composer.json file of your laravel project will look something like below:
它会在你的项目目录中生成一个文件(composer.json)来跟踪所有包。你的 Laravel 项目的默认 composer.json 文件将如下所示:

{
"name": "laravel/laravel",

"name": "laravel/laravel",
"type": "project",
"type": "project",
"description": "The Laravel Framework.",
"description": "The Laravel Framework.",
"keywords": [
"keywords": [
"framework",
"framework",
"laravel"
"laravel"
],
"license": "MIT",
"license": "MIT",
"require": {
"require": {
"php": "^7.3|^8.0",
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^8.12",
"laravel/framework": "^8.12",
"laravel/tinker": "^2.5"
"laravel/tinker": "^2.5"
},
"require-dev": {
"require-dev": {
"facade/ignition": "^2.5",
"facade/ignition": "^2.5",
"fakerphp/faker": "^1.9.1",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^5.0",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.3.3"
"phpunit/phpunit": "^9.3.3"
}
}
The “require” and “require-dev” keys in composer.json specify production and dev packages and their version constraints respectively.
composer.json 中的“require”和“require-dev”键分别指定了生产环境和开发环境的包及其版本约束。

183. 解释 RESTful API(RESTful Application Programming Interface)设计的最佳实践(Best Practices),以及在Macquarie Banking中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: macquarie, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Macquarie Group
  • id: 69b37bc058d557c902bb3ef9 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

184. Name the design patterns in Magento 2.

列出 Magento 2 中的设计模式。
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f08 | 官方: 否 | 付费: 否

答案:

There are a total of 20 design patterns in Magento. These patterns include: - Factory Pattern

Magento 中共有20种设计模式。这些模式包括:- 工厂模式
  • Singleton Pattern
  • Model View Controller Pattern
  • Front Controller Pattern
  • Registry Pattern
  • Prototype Pattern
  • Iterator Pattern
  • Object Pool Pattern
  • Service Locator Pattern
  • Lazy Loading Pattern
  • Observer Pattern
  • Module Pattern
  • Service Contract
  • Object Manager (which consists of 11+ Design Patterns)
  • Proxy Pattern
  • Factory Classes
  • Dependency Injection
  • Injectable Objects
  • Non-injectable objects
  • Active records

185. Distinguish between the EAV and flat model.

区分 EAV 和平面模型。
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f0b | 官方: 否 | 付费: 否

答案:

The EAV database model is completely normalized. Each column's value is stored in its data type database, making it more complicated because they must combine 5-6 tables even if only one detail is required. Columns are referred to as characteristics in EAV.

EAV 数据库模型是完全规范化的。每列的值都存储在其数据类型数据库中,这使得它更加复杂,因为即使只需要一个细节,也必须组合5-6个表。在 EAV 中,列被称为特性。

Only one table is used in the flat model. It isn't normalized, thus it takes up extra space in the database. It's not ideal for dynamic requirements in which you could need to add extra columns in the future. Its performance is quick because it only requires one query rather than joining 5-6 tables. Columns are referred to as fields in the flat model.

平面模型中只使用一个表。它不是规范化的,因此会占用数据库中额外的空间。对于未来可能需要添加额外列的动态需求来说,它不是理想的选择。它的性能很快,因为它只需要一次查询,而不是连接5-6个表。在平面模型中,列被称为字段。

186. In Magento 2, how can you make a custom module?

在 Magento 2 中,如何创建自定义模块?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f0e | 官方: 否 | 付费: 否

答案:

Assume the model is called 'hosting.' You must find it in the app/code folder.

假设模块名为“hosting”。你必须在app/code文件夹中找到它。

It should be something like this: app/code/VendorName/moduleName .

它应该类似这样:app/code/VendorName/moduleName。

For eg, App/code/Interviewvbit/Hosting

例如,App/code/Interviewvbit/Hosting

To develop a custom module in Magento 2, follow the instructions below. - Make a folder for the 'hosting' module.

要在Magento 2中开发自定义模块,请遵循以下说明。- 为“hosting”模块创建一个文件夹。
  • Make a file called etc/module.xml.
  • Make a file called etc/registration.php.
  • Activate the module.

187. What are some of Magento's features?

Magento的一些特性有哪些?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f11 | 官方: 否 | 付费: 否

答案:

The following are the basic characteristics of Magento. - Search Engine Optimized.

以下是Magento的基本特征。- 搜索引擎优化。
  • Support for Google sitemaps.
  • Customers' Accounts.
  • Order management.
  • Analysis and report.
  • Payment .
  • Site management.
  • Promotion and tools for marketing.
  • Support from Community.
  • Architecture which is extremely modular.

188. What types of tables will be created when a new EAV module is built?

构建新的EAV模块时,会创建哪些类型的表?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f14 | 官方: 否 | 付费: 否

答案:

When you construct a new EAV module, six tables will be created. They include: - Module_datetime

当你构建一个新的EAV模块时,将创建六个表。它们包括:- Module_datetime
  • Module
  • Module_decimal
  • Module_int
  • Module_text
  • Module_varchar
  • Data Science
  • All Events
  • My Events

189. What is the technology stack used by Magento?

Magento使用的技术栈是什么?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f17 | 官方: 否 | 付费: 否

答案:

Magento makes use of the MySQL or MariaDB databases, the PHP programming language, and Zend Framework components. PHP 7.0.2 to 7.0.10 is used in Magento 2. However, PHP 7.0.5 is an exception due to a problem with the Magento code compiler in this version.

Magento使用MySQL或MariaDB数据库、PHP编程语言和Zend Framework组件。Magento 2使用PHP 7.0.2到7.0.10版本。然而,PHP 7.0.5是个例外,因为该版本的Magento代码编译器存在问题。

190. How can Magento be made more secure for the client?

如何使Magento对客户端更安全?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f1a | 官方: 否 | 付费: 否

答案:

Any e-commerce website's security is always a priority. Security is also very important in Magento; it is always a top focus.

任何电商网站的安全性始终是优先考虑的事项。安全在Magento中也非常重要;它始终是首要关注点。

You may strengthen Magento's security by following the steps below: - You must develop a strong password and update it regularly.

你可以通过以下步骤加强Magento的安全性:- 你必须设置强密码并定期更新。
  • Allowing remote access to the Magento content manager is not recommended.
  • On production sites, do not distribute downloadable media.
  • Install a Magento website security extension. This module not only protects your store from prospective hackers but also provides an advanced alarm system that allows you to deal with them quickly.

191. How can you add blogs in Magento?

如何在Magento中添加博客?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f1d | 官方: 否 | 付费: 否

答案:

We all know that blogs are important for enhancing a website's search engine rankings. As a result, you should consider adding blogs to your website to improve it and attract more visitors.

我们都知道博客对于提升网站的搜索引擎排名很重要。因此,你应该考虑在网站中添加博客来改进它并吸引更多访客。

To add a blog to Magento, you have two options: - Use the pre-built Magento blog extension.

要在Magento中添加博客,你有两个选项:- 使用预构建的Magento博客扩展。
  • Create a bespoke blog module on the webshop.
    Mageplaza Blog for Magento 2 is an excellent alternative if you want to set up a free readymade blog module. If you want to make a custom blog, on the other hand, you'll need to design a module, which isn't straightforward.

    Mageplaza Blog for Magento 2 是如果您想设置一个免费现成的博客模块的绝佳替代方案。另一方面,如果您想制作自定义博客,则需要设计一个模块,而这并不简单。

192. Describe the various deploy modes in Magento?

描述 Magento 中有哪些不同的部署模式?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f20 | 官方: 否 | 付费: 否

答案:

Magento 2 has four possible deployment modes. - Default mode: You may install Magento 2 apps on a single server using this option. This mode, however, is not suitable for production.

Magento 2 有四种可能的部署模式。- 默认模式:您可以使用此选项在单个服务器上安装 Magento 2 应用程序。但是,此模式不适合生产环境。
  • Developer mode: It is used when you want to change or enhance the functionality of the website.
  • Production: When your Magento 2 site is in production, this option is activated.
  • Maintenance: When you enable this mode, you will be unable to access the Magento website while it is being updated or reconfigured.

193. How can you improve the performance of Magento 2?

如何提高 Magento 2 的性能?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f23 | 官方: 否 | 付费: 否

答案:

We can improve Magento's performance by doing the following: - Disable all modules on the website that you don't use.

我们可以通过以下方式来提高 Magento 的性能:- 禁用网站上所有您不使用的模块。
  • Disable Magento's log.
  • Query Caching in MySQL
  • Optimize the website's image.
  • Gzip compression should be enabled.
  • Magento Caching should be enabled.
  • Make a single file with all of the external CSS/JS.
  • Make use of a Content Delivery Network (CDN) (CDN)
    All of the above will increase the speed of your Magento website, making it more responsive and performant. It not only makes your business more easily, but it also helps your clients have a better online shopping experience.

    上述所有措施都将提高您 Magento 网站的速度,使其更具响应性和高性能。这不仅让您的业务更轻松,还有助于您的客户获得更好的在线购物体验。

194. Explain in brief the EAV model?

简要解释 EAV 模型是什么?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f26 | 官方: 否 | 付费: 否

答案:

The EAV model (Entry, Attribute, Value) is also known as object-attribute-value or Open Schema. Magento makes use of a database or catalog management system.

EAV 模型(条目、属性、值)也称为对象-属性-值或开放架构。Magento 使用数据库或目录管理系统。

EAV is intended for databases in which a high number of attributes are used to identify a single entity, but not all of these attributes are relevant to that entity.

EAV 旨在用于使用大量属性来识别单个实体的数据库,但并非所有这些属性都与该实体相关。

When you use this model, only non-empty data values are kept. Although this model allows for more efficient storage, it is more complicated than the flat model since developers must execute many queries to obtain all of the information about a product or item.

当您使用此模型时,仅保留非空数据值。尽管此模型允许更高效的存储,但它比平面模型更复杂,因为开发人员必须执行多次查询才能获得有关产品或项目的所有信息。

195. What are the limitations of Magento software?

Magento 软件有哪些局限性?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f29 | 官方: 否 | 付费: 否

答案:

Magento is one of the most popular e-commerce platforms available. There's no doubt that the platform is extremely beneficial for e-commerce companies.

Magento 是可用的最受欢迎的电子商务平台之一。毫无疑问,该平台对电子商务公司极为有益。

Its drawback is that it needs an excessive amount of storage and memory. It also necessitates object-oriented programming to avoid becoming a complicated system. Furthermore, Magento has the potential to slow down and degrade the speed of your website. After all, these limits aren't a major deal because, in most circumstances, the benefits of building a website on the Magento platform much exceed any possible drawbacks.

其缺点是它需要过多的存储空间和内存。它还需要面向对象的编程以避免成为复杂的系统。此外,Magento 有可能降低和削弱您网站的速度。毕竟,这些限制并不是大问题,因为在大多数情况下,在 Magento 平台上构建网站的好处远远超过任何可能的缺点。

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

196. What is Model View Controller (MVC) architecture?

什么是模型视图控制器(MVC)架构?
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f2c | 官方: 否 | 付费: 否

答案:

Model-View-Controller (MVC) is a well-known Magento architecture on the market today. Model, View, and Controller are the three sections. The data and logic for operating an application will be handled by the model. The view is a lot of what you see on the application's interface, and it also lets you display whatever you want. Depending on the user's needs, the Controller will pass or issue commands to the view and model.

模型-视图-控制器(MVC)是目前市场上众所周知的 Magento 架构。它分为模型、视图和控制器三个部分。操作应用程序的数据和逻辑将由模型处理。视图是您在应用程序界面上看到的大部分内容,它还允许您显示任何您想要的内容。根据用户的需求,控制器会向视图和模型传递或发出命令。

Convention-based and configuration-based MVC are the two forms of MVC currently available. Magento has been using a configuration-based version up until now. To operate with the website, you'll also need a module configuration file.

基于约定和基于配置的 MVC 是目前可用的两种 MVC 形式。Magento 到目前为止一直使用基于配置的版本。要操作网站,您还需要一个模块配置文件。

197. Name the different versions available in Magento.

命名 Magento 中可用的不同版本。
  • 知识点: 后端 (主题: magento, ecommerce;标签: interviewbit, magento-2, topic-specific, magento, ecommerce)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bc058d557c902bb3f2f | 官方: 否 | 付费: 否

答案:

Magento is a platform that offers a wide range of items. They have been divided apart depending on a variety of options: - Magento Commerce.

Magento 是一个提供多种产品的平台。它们根据各种选项被划分开来:- Magento Commerce。
  • Magento Order Management.
  • Magento Business Intelligence.
  • Magento Shipping Magento Social.
  • Magento Open Source.
    Magento 2.4 is the most recent version. It offers new features and enhancements such as the B2B Module, ElasticSearch, Adobe Sensei-powered Product Recommendations, Adobe Stock Integration, and more. This is the most anticipated version of companies up to this point since it provides a slew of new capabilities to e-commerce sites.

    Magento 2.4 是最新版本。它提供了新功能和增强,例如 B2B 模块、ElasticSearch、由 Adobe Sensei 驱动的产品推荐、Adobe Stock 集成等。到目前为止,这是企业最期待的版本,因为它为电子商务网站提供了大量新功能。

198. Name some famous companies that use Microservice architecture.

列举一些使用微服务架构的知名公司。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a0f | 官方: 否 | 付费: 否

答案:

Microservices architecture has replaced monolithic architecture for most large-scale websites like: - Twitter

对于大多数大规模网站,微服务架构已取代单体架构,例如:- Twitter
  • Netflix
  • Amazon, etc.

199. Explain CDC.

解释 CDC。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a15 | 官方: 否 | 付费: 否

答案:

As the name implies, CDC (Consumer-Driven Contract) basically ensures service communication compatibility by establishing an agreement between consumers and service providers regarding the format of the data exchanged between them. An agreement like this is called a contract. Basically, it is a pattern used to develop Microservices so that they can be efficiently used by external systems.

顾名思义,CDC(消费者驱动契约)基本上通过建立消费者与服务提供商之间关于交换数据格式的协议,来确保服务通信的兼容性。这样的协议被称为契约。基本上,它是一种用于开发微服务的模式,以便外部系统能高效地使用这些微服务。

200. What issues are generally solved by spring clouds?

Spring Cloud 通常解决哪些问题?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a29 | 官方: 否 | 付费: 否

答案:

The following problems can be solved with spring cloud: - Complicated issues caused by distributed systems: This includes network issues, latency problems, bandwidth problems, and security issues.

以下问题可以通过 Spring Cloud 解决:- 由分布式系统引起的复杂问题:包括网络问题、延迟问题、带宽问题和安全问题。
  • Service Discovery issues: Service discovery allows processes and services to communicate and locate each other within a cluster.
  • Redundancy issues: Distributed systems can often have redundancy issues.
  • Load balancing issues: Optimize the distribution of workloads among multiple computing resources, including computer clusters, central processing units, and network links.
  • Reduces performance issues: Reduces performance issues caused by various operational overheads.

201. Write main components of Microservices.

写出微服务的主要组件。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a2c | 官方: 否 | 付费: 否

答案:

Some of the main components of microservices include: - Containers, Clustering, and Orchestration

微服务的一些主要组件包括:- 容器、集群和编排
  • IaC [Infrastructure as Code Conception]
  • Cloud Infrastructure
  • API Gateway
  • Enterprise Service Bus
  • Service Delivery

202. What are the benefits and drawbacks of Microservices?

微服务的优点和缺点是什么?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a2f | 官方: 否 | 付费: 否

答案:

Benefits: - Self-contained, and independent deployment module.

优点:- 自包含且独立部署的模块。
  • Independently managed services.
  • In order to improve performance, the demand service can be deployed on multiple servers.
  • It is easier to test and has fewer dependencies.
  • A greater degree of scalability and agility.
  • Simplicity in debugging & maintenance.
  • Better communication between developers and business users.
  • Development teams of a smaller size.
    Drawbacks: - Due to the complexity of the architecture, testing and monitoring are more difficult.

    缺点:- 由于架构的复杂性,测试和监控更加困难。
  • Lacks the proper corporate culture for it to work.
  • Pre-planning is essential.
  • Complex development.
  • Requires a cultural shift.
  • Expensive compared to monoliths.
  • Security implications.
  • Maintaining the network is more difficult.

203. Name three common tools mostly used for microservices.

列举三个常用于微服务的工具。
  • 知识点: 后端 / 系统设计/架构 / 行为与软技能 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a32 | 官方: 否 | 付费: 否

答案:

Three common tools used for microservices include: - Wiremock

常用于微服务的三个工具包括:- Wiremock
  • Docker
  • Hystrix

204. Explain the working of Microservice Architecture.

解释微服务架构的工作原理。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a35 | 官方: 否 | 付费: 否

答案:

Microservice architectures consist of the following components:

微服务架构由以下组件组成:
  • Clients: Different users send requests from various devices.
  • Identity Provider: Validate a user's or client's identity and issue security tokens.
  • API Gateway: Handles the requests from clients.
  • Static Content: Contains all of the system's content.
  • Management: Services are balanced on nodes and failures are identified.
  • Service Discovery: A guide to discovering the routes of communication between microservices.
  • Content Delivery Network: Includes distributed network of proxy servers and their data centers.
  • Remote Service: Provides remote access to data or information that resides on networked computers and devices.

205. Write difference between Monolithic, SOA and Microservices Architecture.

写出单体架构、SOA 和微服务架构之间的区别。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a38 | 官方: 否 | 付费: 否

答案:

  • Monolithic Architecture: It is "like a big container" where all the software components of an application are bundled together tightly. It is usually built as one large system and is one code-base.
  • SOA (Service-Oriented Architecture): It is a group of services interacting or communicating with each other. Depending on the nature of the communication, it can be simple data exchange or it could involve several services coordinating some activity.
  • Microservice Architecture: It involves structuring an application in the form of a cluster of small, autonomous services modeled around a business domain. The functional modules can be deployed independently, are scalable, are aimed at achieving specific business goals, and communicate with each other over standard protocols.

206. Explain spring cloud and spring boot.

解释 Spring Cloud 和 Spring Boot。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a3b | 官方: 否 | 付费: 否

答案:

Spring Cloud : In Microservices, the Spring cloud is a system that integrates with external systems. This is a short-lived framework designed to build applications quickly. It contributes significantly to microservice architecture due to its association with finite amounts of data processing. Some of the features of spring cloud are shown below:

Spring Cloud:在微服务中,Spring Cloud 是一个与外部系统集成的系统。这是一个短生命周期的框架,旨在快速构建应用程序。由于它与有限的数据处理量相关联,它对微服务架构贡献显著。Spring Cloud 的一些功能如下所示:

Spring Boot: Spring Boot is an open-sourced, Java-based framework that provides its developers with a platform on which they can create stand-alone, production-grade Spring applications. In addition to reducing development time and increasing productivity, it is easily understood.

Spring Boot:Spring Boot 是一个开源的、基于 Java 的框架,为开发者提供一个平台,使他们能够创建独立的、生产级别的 Spring 应用程序。除了减少开发时间和提高生产力外,它还易于理解。

207. What is the role of actuator in spring boot?

Actuator 在 Spring Boot 中的作用是什么?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a3e | 官方: 否 | 付费: 否

答案:

A spring boot actuator is a project that provides restful web services to access the current state of an application that is running in production. In addition, you can monitor and manage application usage in a production environment without having to code or configure any of the applications.

Spring Boot Actuator 是一个项目,提供 RESTful Web 服务来访问在生产环境中运行的应用程序的当前状态。此外,您可以在无需编码或配置任何应用程序的情况下,监控和管理生产环境中的应用程序使用情况。

208. Explain how you can override the default properties of Spring boot projects.

解释如何覆盖 Spring Boot 项目的默认属性。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a41 | 官方: 否 | 付费: 否

答案:

By specifying properties in the application.properties file, it is possible to override the default properties of a spring boot project. Example: In Spring MVC applications, you need to specify a suffix and prefix. You can do this by adding the properties listed below in the application.properties file. - For suffix – spring.mvc.view.suffix: .jsp

通过指定 application.properties 文件中的属性,可以覆盖 Spring Boot 项目的默认属性。示例:在 Spring MVC 应用程序中,您需要指定后缀和前缀。您可以通过在 application.properties 文件中添加以下属性来实现。- 对于后缀 – spring.mvc.view.suffix: .jsp
  • For prefix – spring.mvc.view.prefix: /WEB-INF/

209. Write main features of Microservices.

写出微服务的主要功能。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a45 | 官方: 否 | 付费: 否

答案:

Some of the main features of Microservices include:

微服务的一些主要功能包括:
  • Decoupling: Within a system, services are largely decoupled. The application as a whole can therefore be easily constructed, altered, and scalable
  • Componentization: Microservices are viewed as independent components that can easily be exchanged or upgraded
  • Business Capabilities: Microservices are relatively simple and only focus on one service
  • Team autonomy: Each developer works independently of each other, allowing for a faster project timeline
  • Continuous Delivery: Enables frequent software releases through systematic automation of software development, testing, and approval
  • Responsibility: Microservices are not focused on applications as projects. Rather, they see applications as products they are responsible for
  • Decentralized Governance: Choosing the right tool according to the job is the goal. Developers can choose the best tools to solve their problems
  • Agility: Microservices facilitate agile development. It is possible to create new features quickly and discard them again at any time.

210. What do you mean by Cohesion and Coupling?

你所说的内聚和耦合是什么意思?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a4a | 官方: 否 | 付费: 否

答案:

Coupling : It is defined as a relationship between software modules A and B, and how much one module depends or interacts with another one. Couplings fall into three major categories. Modules can be highly coupled (highly dependent), loosely coupled, and uncoupled from each other. The best kind of coupling is loose coupling, which is achieved through interfaces. Cohesion : It is defined as a relationship between two or more parts/elements of a module that serves the same purpose. Generally, a module with high cohesion can perform a specific function efficiently without needing communication with any other modules. High cohesion enhances the functionality of the module.

耦合:它被定义为软件模块 A 和 B 之间的关系,以及一个模块依赖于或与另一个模块交互的程度。耦合分为三大类。模块可以是高耦合的(高度依赖)、松耦合的以及彼此无耦合的。最好的耦合类型是松耦合,它是通过接口实现的。内聚:它被定义为模块中服务于相同目的的两个或多个部分/元素之间的关系。通常,高内聚的模块可以有效地执行特定功能,而无需与其他模块通信。高内聚增强了模块的功能性。

211. What do you mean by Bounded Context?

你所说的有界上下文是什么意思?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bce58d557c902bb4a4d | 官方: 否 | 付费: 否

答案:

A Bounded Context is a central pattern in DDD (Domain-Driven Design), which deals with collaboration across large models and teams. DDD breaks large models down into multiple contexts to make them more manageable. Additionally, it explains their relationship explicitly. The concept promotes an object-oriented approach to developing services bound to a data model and is also responsible for ensuring the integrity and mutability of said data model.

有界上下文是 DDD(领域驱动设计)中的核心模式,它处理大型模型和团队之间的协作。DDD 将大型模型分解为多个上下文,使其更易于管理。此外,它还明确解释了它们之间的关系。该概念提倡一种面向对象的方法来开发绑定到数据模型的服务,并负责确保该数据模型的完整性和可变性。

212. Write the fundamental characteristics of Microservice Design.

写出微服务设计的基本特征。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bcf58d557c902bb4a50 | 官方: 否 | 付费: 否

答案:

  • Based on Business Capabilities: Services are divided and organized around business capabilities.
  • Products not projects: A product should belong to the team that handles it.
  • Essential messaging frameworks: Rely on functional messaging frameworks: Eliminate centralized service buses by embracing the concept of decentralization.
  • Decentralized Governance: The development teams are accountable for all aspects of the software they produce.
  • Decentralized data management: Microservices allow each service to manage its data separately.
  • Automated infrastructure: These systems are complete and can be deployed independently.
  • Design for failure: Increase the tolerance for failure of services by focusing on continuous monitoring of the applications.

213. What are the challenges that one has to face while using Microservices?

使用微服务时需要面对的挑战有哪些?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bcf58d557c902bb4a53 | 官方: 否 | 付费: 否

答案:

The challenges that one has to face while using microservices can be both functional and technical as given below: Functional Challenges: - Require heavy infrastructure setup.

使用微服务时需要面对的挑战既包括功能性的,也包括技术性的,具体如下:功能性挑战:- 需要大量的基础设施搭建。
  • Need Heavy investment.
  • Require excessive planning to handle or manage operations overhead.
    Technical Challenges: - Microservices are always interdependent. Therefore, they must communicate with each other.

    技术性挑战:- 微服务总是相互依赖的。因此,它们必须相互通信。
  • It is a heavily involved model because it is a distributed system.
  • You need to be prepared for operations overhead if you are using Microservice architecture.
  • To support heterogeneously distributed microservices, you need skilled professionals.
  • It is difficult to automate because of the number of smaller components. For that reason, each component must be built, deployed, and monitored separately.
  • It is difficult to manage configurations across different environments for all components.
  • Challenges associated with deployment, debugging, and testing.

214. Explain PACT in microservices.

解释微服务中的PACT。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bcf58d557c902bb4a56 | 官方: 否 | 付费: 否

答案:

PACT is defined as an open-source tool that allows service providers and consumers to test interactions in isolation against contracts that have been made to increase the reliability of microservice integration. It also offers support for numerous languages, such as Ruby, Java, Scala, .NET, JavaScript, Swift/Objective-C.

PACT被定义为一个开源工具,它允许服务提供者和消费者根据已制定的契约,在隔离环境中测试交互,以提高微服务集成的可靠性。它还支持多种语言,如Ruby、Java、Scala、.NET、JavaScript、Swift/Objective-C。

215. Explain how independent microservices communicate with each other.

解释独立的微服务如何相互通信。
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bcf58d557c902bb4a59 | 官方: 否 | 付费: 否

答案:

Communication between microservices can take place through: - HTTP/REST with JSON or binary protocol for request-response

微服务之间的通信可以通过以下方式实现:- 使用HTTP/REST配合JSON或二进制协议进行请求-响应
  • Websockets for streaming.
  • A broker or server program that uses advanced routing algorithms.
    RabbitMQ, Nats, Kafka, etc., can be used as message brokers; each is built to handle a particular message semantic. You can also use Backend as a Service like Space Cloud to automate your entire backend.

    RabbitMQ、Nats、Kafka等可以用作消息代理;每个都旨在处理特定的消息语义。你也可以使用像Space Cloud这样的后端即服务来自动化你的整个后端。

216. What do you mean by client certificates?

客户端证书是什么意思?
  • 知识点: 后端 / 系统设计/架构 (主题: microservices, architecture;标签: interviewbit, microservices, topic-specific, architecture)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bcf58d557c902bb4a5c | 官方: 否 | 付费: 否

答案:

The client certificate is a type of digital certificate that generally allows client systems to authenticate their requests to remote servers. In many mutual authentication designs, it plays a key role in providing strong assurance of the requestor's identity.

客户端证书是一种数字证书,通常允许客户端系统向远程服务器验证其请求。在许多相互认证设计中,它在提供请求者身份的强保证方面起着关键作用。

217. What are Connectors in Mule?

Mule中的连接器是什么?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e21 | 官方: 否 | 付费: 否

答案:

Connectors in Mule are Mule’s abstraction for sending and receiving data and interacting with various APIs. There are generally 2 forms of connectors in Mule: - Transport: This is the most common form of connector used in Mule. Like HTTP, transports provide an adaptation layer for a protocol. These are the sources and sinks for data - to get data into and out of flows.

Mule中的连接器是Mule用于发送和接收数据以及与各种API交互的抽象。Mule中通常有两种形式的连接器:- 传输:这是Mule中最常用的连接器形式。像HTTP一样,传输为协议提供适配层。这些是数据的源和汇——用于将数据获取到流程中或从流程中导出。
  • Cloud connectors: These are typically used to interact with an API. Usually, cloud connectors don’t give endpoints. Instead, they have message processors that map to the operations provided in the API. The operations of an API are combined by these cloud connectors. The effect of this is that the initial friction for a developer is greatly reduced.

218. What are the different tools and services offered by Mulesoft?

Mulesoft提供了哪些不同的工具和服务?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e24 | 官方: 否 | 付费: 否

答案:

MuleSoft helps in the task of data integration diligently and efficiently. The tools and services offered by MuleSoft include: - API Designer: API Designer is a web-based tool that contains a console and a scripting notebook for JavaScript.

MuleSoft致力于勤勉高效地完成数据集成任务。MuleSoft提供的工具和服务包括:- API Designer:API Designer是一个基于Web的工具,包含一个控制台和一个用于JavaScript的脚本笔记本。
  • API Manager: API Manager is a management tool that allows organizations in managing users, traffic, and service level agreements.
  • Anypoint Studio: Anypoint Studio is a graphical design environment to build and edit APIs and integrations.
  • API Portal: This is a portal that offers developers different kinds of documents, tutorials, and code snippets related to APIs.
  • API Analytics: API Analytics is an analytics tool that allows a user to track the specifications of an API. This also includes its performance, usage, and reliability. Additionally, it offers a dashboard and charts.

219. What is Mule ESB?

什么是Mule ESB?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e27 | 官方: 否 | 付费: 否

答案:

Mule ESB stands for Mule Enterprise Service Bus . Mule ESB makes it easy for the development teams to flexibly connect, access, and exchange data easily. This means that even though the application is running into different VMs, the interactions between them are easy.

Mule ESB 代表 Mule 企业服务总线。Mule ESB 使开发团队能够轻松灵活地连接、访问和交换数据。这意味着即使应用程序运行在不同的虚拟机中,它们之间的交互也很容易。

Following are some of the features of Mule ESB: - Message Transformation Service

以下是 Mule ESB 的一些特性:- 消息转换服务
  • Set of Service Container
  • Web Service Security
  • Message Routing Service
  • Simple drag-and-drop graphical design
  • Centralized monitoring and administration

220. What are Batch Jobs in Mule ESB?

什么是 Mule ESB 中的批处理作业?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e2a | 官方: 否 | 付费: 否

答案:

In Mule ESB, a batch job is an element in a mule that splits large messages into records. These records are then processed asynchronously in a batch job.

在 Mule ESB 中,批处理作业是 mule 中的一个元素,它将大消息拆分为记录。这些记录随后在批处理作业中异步处理。

Within an application, one can initiate a Batch Job scope, which splits messages into individual records, performs actions upon each record, and then reports on the results and potentially pushes the processed output to other systems or queues. With this, we can handle large quantities of incoming data from an API into a legacy system. We can also synchronize data sets between business applications.

在应用程序内,可以启动批处理作业作用域,它将领消息拆分为单独的记录,对每条记录执行操作,然后报告结果,并可能将处理后的输出推送到其他系统或队列。通过这种方式,我们可以处理来自 API 进入传统系统的大量传入数据。我们还可以在业务应用之间同步数据集。

221. What are the different types of variables in MuleSoft?

MuleSoft 中有哪些不同类型的变量?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e2d | 官方: 否 | 付费: 否

答案:

The different types of variables in MuleSoft are as follows: - Flow Variable: This is used to either set or remove variables that are tied to a particular message in the current flow.Syntax: #[flowVars.Code]

MuleSoft 中不同类型的变量如下:- 流变量:用于设置或移除与当前流中特定消息关联的变量。语法:#[flowVars.Code]
  • Record Variable: This is used for the batch processing flows. Unlike any other variable, these are special variable sets that are used only inside a Batch Job.Syntax: #[recordVars.Code]
  • Session Variable: This is used to either set or remove variables tied to a particular message for the entire lifecycle. Syntax: #[sessionVars.Code]

222. What are the different types of messages in MuleSoft?

MuleSoft 中有哪些不同类型的消息?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e30 | 官方: 否 | 付费: 否

答案:

  • Echo and Log message - These are used to log messages and move them from inbound to outbound routers. Inbound Routers means a single event is received via an endpoint and the router controls how and if this event gets routed into the system. Outbound routers mean once a message has been processed by a component an outbound router can be used to determine which components get the result event.
  • Bridge Message - This is a passed message from inbound to outbound routers.
  • Build Message - These are messages created from fixed or dynamic values.

223. What are the different Primitives used in Mediation?

中介中使用的不同原语有哪些?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e33 | 官方: 否 | 付费: 否

答案:

Mediation is used for personalizing interactions between distributed applications and service components. The following are the different Primitives used in Mediation: - Message Filter

中介用于个性化分布式应用和服务组件之间的交互。以下是中介中使用的不同原语:- 消息过滤器
  • Type Filter
  • Endpoint Lookup
  • Service Invoke
  • Fan-out
  • Fan-in
  • XSLT
  • BO Map
  • Message Element Setter
  • DB lookup
  • Data Handler
  • Custom Mediation
  • Header Setters
  • Message Logger
  • Even Emitter
  • Stop
  • Fail
  • Sub Flow

224. What is a shared resource in Mule?

什么是 Mule 中的共享资源?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e36 | 官方: 否 | 付费: 否

答案:

In Mule, shared resources are common resources that are exposed to all applications deployed under the same domain. Sharing resources allows different development teams to work in parallel.

在 Mule 中,共享资源是暴露给同一域下部署的所有应用程序的公共资源。共享资源允许不同的开发团队并行工作。

For instance : Connector configurations could be made a reusable resource. These could be shared among all applications deployed.

例如:连接器配置可以做成可重用的资源。这些可以在所有部署的应用程序之间共享。

These shared resources should be defined in the Mule Domain Project. These should then be referred to each of the projects that are meant to use the elements in it.

这些共享资源应在 Mule 域项目中定义。然后应在每个意图使用其中元素的项目中引用它们。

225. What are the Models?

什么是模型?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e39 | 官方: 否 | 付费: 否

答案:

In Mulesoft studio, the grouping of services (application objects and their attributes) created are called Models. Through this, a user can start and stop the services inside a given model.

在 Mulesoft studio 中,所创建的服务分组(应用程序对象及其属性)称为模型。通过此功能,用户可以在给定模型中启动和停止服务。

226. What is Mule?

什么是 Mule?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e3c | 官方: 否 | 付费: 否

答案:

Mule is an open-source enterprise integration platform that helps tackle the problems in developing integration applications. Some of the problems that are tackled by Mule include Error handling, Monitoring, Lifecycle and management, Data format, etc. Thus, with these problems gone, Mule helps focus on the application’s core requirements like scalability and efficiency.

Mule 是一个开源的企业集成平台,旨在帮助解决开发集成应用程序时遇到的问题。Mule 解决的一些问题包括错误处理、监控、生命周期和管理、数据格式等。因此,随着这些问题的消除,Mule 有助于专注于应用程序的核心需求,如可扩展性和效率。

227. What is a runtime manager in Mule?

什么是 Mule 中的运行时管理器?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e3f | 官方: 否 | 付费: 否

答案:

In Mule, a runtime manager is used for deploying and managing Mule applications. This is done on the Mule runtime engine where Mule runtime is running. We can deploy or pause the mule application by using runtime manager. We can also change the runtime version of the application at a given time. The worker size can be increased or decreased as well.

在 Mule 中,运行时管理器用于部署和管理 Mule 应用程序。这是在 Mule 运行时引擎上执行的,其中 Mule 运行时正在运行。通过使用运行时管理器,我们可以部署或暂停 Mule 应用程序。我们还可以在给定时间更改应用程序的运行时版本。工作线程大小也可以增加或减少。

228. What is Worker in MuleSoft?

什么是 MuleSoft 中的 Worker?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e42 | 官方: 否 | 付费: 否

答案:

In Mulesoft, Worker is a dedicated instance of Mule hosted on AWS that is used to run the integration applications.

在 MuleSoft 中,Worker 是托管在 AWS 上的 Mule 专用实例,用于运行集成应用程序。

Following are some of the features of workers: - Capacity: For the purpose of data processing, every worker has a given amount of capacity.

以下是 Worker 的一些特性:- 容量:为了数据处理的目的,每个 Worker 都有一定量的容量。
  • Isolation: Isolation means that every worker runs in a separate container from every other application.
  • Manageability: Manageability means that the deployment and management of each worker are done independently.
  • Locality: In this feature, every worker runs and is located on a specific worker cloud.

229. What is Mule Runtime?

什么是 Mule 运行时?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e45 | 官方: 否 | 付费: 否

答案:

A runtime engine that is used to host and run Mule applications, is called a Mule runtime. This is similar to an application server. Mule runtimes can be provisioned either on the premises or also on the cloud. A single Mule runtime can host several Mule applications. Here is the figure representing Mule runtime.

用于托管和运行 Mule 应用程序的运行时引擎称为 Mule 运行时。这类似于应用服务器。Mule 运行时可以在本地或云上进行配置。单个 Mule 运行时可以托管多个 Mule 应用程序。下图表示 Mule 运行时。

230. How is Reliability achieved in MuleSoft?

如何在 MuleSoft 中实现可靠性?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e48 | 官方: 否 | 付费: 否

答案:

Reliability in Mule means Zero message loss. To make this happen, applications must be designed in a way to capture the state of a running process/instance, which can be picked up by another running node in the cluster. Reliable messaging is given by built-in support of transactions in transport, if the application uses a transactional transport such as Java Message Service (JMS), Virtual Machine (VM), Database (DB), etc. A reliable messaging pattern is essential when dealing with non-transactional endpoints.

Mule 中的可靠性意味着零消息丢失。为了实现这一点,应用程序必须设计成能够捕获正在运行的进程/实例的状态,该状态可以被集群中的另一个运行节点接管。如果应用程序使用事务性传输(如 Java 消息服务(JMS)、虚拟机(VM)、数据库(DB)等),则通过传输中内建的事务支持来提供可靠消息传递。在处理非事务性端点时,可靠消息传递模式至关重要。

231. How can we improve the performance of the Mule Application in MuleSoft?

在 MuleSoft 中如何提高 Mule 应用程序的性能?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e4b | 官方: 否 | 付费: 否

答案:

The following are some ways to improve the performance of the Mule Application in MuleSoft: - Put the data validation at the start of the flow.

以下是在 MuleSoft 中提高 Mule 应用程序性能的一些方法:- 将数据验证放在流程的开始处。
  • Use Streaming to process data.
  • Save the results of the application and reuse them later.
  • Process data asynchronously wherever is possible.

232. How can Code in MuleSoft be optimized for memory efficiency?

在 MuleSoft 中如何优化代码以提高内存效率?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e4e | 官方: 否 | 付费: 否

答案:

The code in MuleSoft be optimized for memory efficiency in the following ways: - One should not save the payload into the flow variable. This is because it is a more memory consuming element.

在 MuleSoft 中可以通过以下方式优化代码以提高内存效率:- 不应将有效负载保存到流程变量中。这是因为它是一个更消耗内存的元素。
  • The unnecessary part of the document should not be loaded while processing.
  • For highly concurrent scenarios, one should use better database polling.
  • Use Dataweave for transformations.

233. What are Flow Processing Strategies and what are the different types of it?

什么是流程处理策略,其不同类型有哪些?
  • 知识点: 后端 (主题: mulesoft, integration;标签: interviewbit, mulesoft, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37bd758d557c902bb4e51 | 官方: 否 | 付费: 否

答案:

How Mule implements message processing for a given flow is determined by a Flow Processing Strategy. All Mule flows have an implicit processing strategy which Mule applies automatically: either synchronous or queued-asynchronous. Each of these processing strategies is optimal for certain flows.

Mule如何实现给定流的消息处理,由流处理策略决定。所有Mule流都有一个隐式的处理策略,Mule会自动应用:同步或排队异步。每种处理策略都针对特定类型的流进行了优化。

The different types of Flow Processing Strategies are: - Synchronous Flow Processing Strategy.

流处理策略的不同类型包括:- 同步流处理策略。
  • Asynchronous Flow Processing Strategy.
  • Queued Flow Processing Strategy.
  • Queued Asynchronous Flow Processing Strategy.
  • Custom Processing Strategy.
  • Thread Per Processing Strategy.
  • Non-blocking Flow Processing Strategy.

234. 解释 RESTful API(RESTful Application Programming Interface)设计的最佳实践(Best Practices),以及在NAB App(NAB Application)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: nab, generated)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • 公司: Nab
  • id: 69b37bf558d557c902bb5f62 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

235. There is a loop in a linked list if there is some node where the next pointer can be followed to reach the same node again. The index pos is used to denote the node that the tail's next pointer is connected to. Note that pos is not passed as a parameter.

如果链表中存在某个节点,通过跟随next指针可以再次到达同一节点,则链表中存在循环。索引pos用于表示尾节点的next指针所连接的节点。请注意,pos不是作为参数传递的。
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, nagarro, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Nagarro
  • id: 69b37bf958d557c902bb6149 | 官方: 否 | 付费: 否

答案:

Given the linked list, return true if there is a cycle in the linked list. Otherwise, return false.

给定链表,如果链表中存在环,则返回true;否则返回false。

We can use a fast and slow pointer approach and will start traversing the linked list. The slow pointer will move 1 step forward and the fast pointer will move 2 steps forward. If there is a cycle in a linked list, then there will be a time when both the pointers will reach the same position. Then we will return true. Otherwise, if the pointer reaches the null then that means there was no loop in the linked list and then we will return false.

我们可以使用快慢指针方法并开始遍历链表。慢指针每次向前移动1步,快指针每次向前移动2步。如果链表中存在环,那么在某个时刻两个指针将到达相同位置。然后我们将返回true。否则,如果指针到达null,则意味着链表中没有环,然后我们将返回false。

//Method that detects the loop in the linked list.

//检测链表中循环的方法。
public boolean hasCycle(ListNode head) {
public boolean hasCycle(ListNode head) {
if(head == null || head.next == null)
if(head == null || head.next == null)
return false;
返回 false;

//Managing slow and fast pointers.

//管理慢指针和快指针。
ListNode slow = head, fast = head;
ListNode slow = head, fast = head;
/*
moving the pointers slow by 1 position
将慢指针移动 1 个位置
and fast pointer by 2. If they meet that
将快指针移动 2 个位置。如果它们相遇,那
means there is a cycle. So return true.
就意味着存在环。因此返回 true。
*/
while(fast != null && fast.next != null){
while(fast != null && fast.next != null){
fast = fast.next.next;
fast = fast.next.next;
slow = slow.next;
slow = slow.next;
if(slow == fast)
if(slow == fast)
return true;
返回 true;
}
//Otherwise return false if the linked list reaches the end
//否则,如果链表到达末尾,则返回 false
return false; }
return false; }
  • Data Science
  • All Events
  • My Events

236. How can you delete a value from a linked list if you have a pointer to it? It's important to note that no other node, not even the head, is provided with a pointer.

如果你有一个指向链表中某个节点的指针,你如何删除该节点的值?值得注意的是,没有提供指向其他节点(甚至头节点)的指针。
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, nutanix, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Nutanix
  • id: 69b37c0258d557c902bb67b7 | 官方: 否 | 付费: 否

答案:

The approach is to copy the data from the next node to the node that will be erased, then delete the node that will be deleted.

方法是把下一个节点的数据复制到将要被删除的节点,然后删除那个将要被删除的节点。

void delNode(ListNode* ptr)

void delNode(ListNode* ptr)
{
// If the node to be deleted is the
// 如果要删除的节点是
// last node of linked list
// 链表的最后一个节点
if (!ptr->next)
if (!ptr->next)
{
free(ptr);
free(ptr);
// this will simply make the node_ptr NULL.
// 这只会让 node_ptr 变为 NULL。
return;
return;
}

// if node to be deleted is the first or

// 如果要删除的节点是第一个或
// any node in between the linked list.
// 链表中间的任意节点。
ListNode* temp = ptr->next;
ListNode* temp = ptr->next;
ptr->val = temp->val;
ptr->val = temp->val;
ptr->next = temp->next;
ptr->next = temp->next;
free(temp);
free(temp);
}
It's vital to keep in mind that this method will only operate if the given reference does not point to the last node. Because you don't have the following node to copy the info from if it's the last node. We can make the final node a dummy node to make this solution work. However, the programs/functions that use this function should be changed as well.
务必记住,此方法仅在给定引用不指向最后一个节点时有效。因为如果它是最后一个节点,就没有后续节点可供复制信息。我们可以将最后一个节点设为哑节点,使此解决方案奏效。但是,使用此函数的程序/函数也应随之修改。

237. How does spring IoC work?

Spring IoC 是如何工作的?
  • 知识点: 后端 (标签: interviewbit, paypay, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: PayPay
  • id: 69b37c1158d557c902bb7043 | 官方: 否 | 付费: 否

答案:

Spring sets itself apart from other frameworks with features including Spring IOC (Inversion of Control), Spring AOP (Aspect-Oriented Programming), and transaction management. Among the most important components of the Spring Framework is the IOC Container. Objects are created, their dependencies are gathered and configured, and their lifecycle is managed using it. In order to manage the components of the application, the Container utilizes DI (Dependency Injection). Object-related information is obtained from either Java code or configuration files (XML), Java POJO classes, and Java annotations. These objects are known as beans. Because Java objects and their lifecycle are not controlled by developers, the term Inversion Of Control (IoC) has been coined. In the following diagram, you can see how the Container manages beans utilizing Java POJO classes and Configuration metadata.

Spring 凭借 Spring IOC(控制反转)、Spring AOP(面向切面编程)和事务管理等特性,从其他框架中脱颖而出。IOC 容器是 Spring 框架最重要的组件之一。对象的创建、依赖的收集与配置以及生命周期的管理都通过它来完成。为了管理应用程序的组件,容器利用了 DI(依赖注入)。与对象相关的信息可从 Java 代码或配置文件(XML)、Java POJO 类以及 Java 注解中获取。这些对象被称为 bean。由于 Java 对象及其生命周期不再由开发者控制,因此创造了“控制反转”(IoC)这一术语。在下图中,你可以看到容器如何利用 Java POJO 类和配置元数据来管理 bean。

PayPay Interview Preparation

238. What is a session in PHP?

什么是 PHP 中的会话?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74be | 官方: 否 | 付费: 否

答案:

A session in PHP is a way to store information to be used across multiple pages of an entire website. The information is not stored on the user’s computer, unlike cookies. In a temporary directory on the server, a file will be created by the session where registered session variables and their values are stored. This information will be available to all pages on the site during that visit.

PHP中的会话是一种存储信息的方式,用于在整个网站的多页面间使用。与Cookie不同,这些信息不是存储在用户的计算机上。在服务器的一个临时目录中,会话会创建一个文件,其中存储了注册的会话变量及其值。在访问期间,这些信息将对网站的所有页面可用。

When you work with an application, you open it, do some modifications, and then you close it. This is much like a Session. The computer knows who you are. It knows when the application is started and ended by you.

当你使用一个应用程序时,你打开它,进行一些修改,然后关闭它。这很像一个会话。计算机知道你是谁,知道你何时启动和结束应用程序。

But on the internet, the webserver does not know who you are or what you do, because the HTTP address doesn’t maintain a state. This problem is solved using session variables by storing user information to be used across multiple pages (e.g. username, favorite color, etc).

但在互联网上,Web服务器不知道你是谁或你做了什么,因为HTTP地址不维持状态。这个问题通过使用会话变量来解决,存储用户信息以供多个页面使用(例如用户名、喜欢的颜色等)。

By default, session variables will last until the user closes the browser.

默认情况下,会话变量将持续到用户关闭浏览器为止。

So Session variables hold single user information and are available to all pages in one application.

因此,会话变量保存单个用户的信息,并且在一个应用程序中的所有页面都可用。

239. Differentiate between variables and constants in PHP

区分PHP中的变量和常量
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74c4 | 官方: 否 | 付费: 否

答案:

Few difference between variables and constants in PHP are given below:

PHP中变量和常量之间的几个区别如下:
Variables
变量
Constants
常量
The value of a variable can be changed during the execution.
变量的值可以在执行过程中改变。
The constant value can’t be changed during script execution.
常量的值在脚本执行期间不能改变。
Variables require compulsory usage of the $ sign at the start.<br>变量需要在开头强制使用$符号。No dollar sign ($) is required before using a constant.<br>使用常量前不需要美元符号($)。
It is possible to define a variable by simple assignment.
可以通过简单赋值来定义变量。
Constants can’t be defined by simple assignments. They are defined using the define() function.
常量不能通过简单赋值定义,它们使用define()函数定义。
The default scope is the current access scope.
默认作用域是当前访问作用域。
Constants can be accessed throughout without any scoping rules.
常量可以在整个范围内访问,没有任何作用域规则。

240. What does PEAR stands for?

PEAR代表什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74c7 | 官方: 否 | 付费: 否

答案:

PEAR stands for “PHP Extension and Application Repository”. PEAR is a framework and repository for all of the reusable PHP components.

PEAR代表“PHP扩展和应用仓库”。PEAR是一个框架和仓库,用于所有可重用的PHP组件。

PEAR provides a higher level of programming for web developers . It contains all kinds of PHP code snippets and libraries. It also provides you with a command-line interface to automatically install packages.

PEAR为Web开发者提供了更高层次的编程。它包含各种PHP代码片段和库。它还为您提供了一个命令行界面,用于自动安装包。

241. Explain the difference between $message and $$message.

解释$message和$$message之间的区别。
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74ca | 官方: 否 | 付费: 否

答案:

The main difference between the $message and $$message is given below:

$message和$$message之间的主要区别如下:
$message$$message
$message is a regular variable.<br>$message是一个常规变量。$$message is a reference variable.<br>$$message是一个引用变量。
It has a fixed name and stores a fixed value.
它有固定的名称并存储固定的值。
It stores data about the variable.
它存储关于变量的数据。
Data stored in $message is fixed.<br>$message中存储的数据是固定的。The value of the $$message can change dynamically as the value of the variable changes.<br>$$message的值可以随着变量的值变化而动态改变。

242. Is PHP a case-sensitive language?

PHP 是一种区分大小写的语言吗?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74cd | 官方: 否 | 付费: 否

答案:

PHP can be considered as a partial case-sensitive language. The variable names are completely case-sensitive but function names are not. Also, user-defined functions are not case-sensitive but the rest of the language is case-sensitive.

PHP 可以被视为一种部分区分大小写的语言。变量名完全区分大小写,但函数名不区分大小写。此外,用户自定义函数不区分大小写,但语言的其他部分区分大小写。

For example, user-defined functions in PHP can be defined in lowercase but later referred to in uppercase, and it would still function normally.

例如,PHP 中的用户自定义函数可以用小写定义,但之后用大写引用,它仍然能正常工作。
  • Data Science
  • All Events
  • My Events

243. What are the different types of variables present in PHP?

PHP 中存在哪些不同类型的变量?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74d0 | 官方: 否 | 付费: 否

答案:

Types of PHP Variables

PHP 变量的类型

There are 8 primary data types in PHP which are used to construct the variables. They are: - Integers: Integers are whole numbers without a floating-point. Ex: 1253.

PHP 中有 8 种主要数据类型用于构造变量。它们是: - 整数:整数是没有浮点数的完整数字。例如:1253。
  • Doubles: Doubles are floating-point numbers. Ex: 7.876
  • Booleans: It represents two logical states- true or false.
  • NULL: NULL is a special type that only has one value, NULL. When no value is assigned to a variable, it can be assigned with NULL.
  • Arrays: Array is a named and ordered collection of similar type of data. Ex: $colors = array("red", "yellow", "blue");
  • Strings: Strings are a sequence of characters. Ex: “Hello InterviewBit!”
  • Resources: Resources are special variables that consist of references to resources external to PHP(such as database connections).
  • Objects: An instance of classes containing data and functions. Ex: $mango = new Fruit();

244. What are the rules for naming a PHP variable?

PHP 变量命名的规则是什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74d3 | 官方: 否 | 付费: 否

答案:

The following two rules are needed to be followed while naming a PHP variable: - A variable must start with a dollar symbol, followed by the variable name. For example: $price=100; where price is a variable name.

命名 PHP 变量时需要遵循以下两条规则: - 变量必须以美元符号开头,后跟变量名。例如:$price=100;其中 price 是变量名。
  • Variable names must begin with a letter or underscore.
  • A variable name can consist of letters, numbers, or underscores. But you cannot use characters like + , – , % , & etc.
  • A PHP variable name cannot contain spaces.
  • PHP variables are case-sensitive. So $NAME and $name both are treated as different variables.

245. What is the difference between “echo” and “print” in PHP?

PHP 中“echo”和“print”的区别是什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74d6 | 官方: 否 | 付费: 否

答案:

The main difference between echo and print in PHP are given below:

PHP 中 echo 和 print 的主要区别如下:
echoprint
echo can output one or more strings.
echo 可以输出一个或多个字符串。
print can only output one string and it always returns 1.
print 只能输出一个字符串,并且总是返回 1。
echo is faster than print because it does not return any value.
echo 比 print 快,因为它不返回任何值。
print is slower compared to echo.
print 与 echo 相比速度较慢。
If you want to pass more than one parameter to echo, a parenthesis should be used.
如果你想向 echo 传递多个参数,应使用括号。
Use of parenthesis is not required with the argument list.
参数列表不需要使用括号。

246. Tell me some of the disadvantages of PHP

告诉我一些 PHP 的缺点
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74d9 | 官方: 否 | 付费: 否

答案:

The cons of PHP are: - PHP is not suitable for giant content-based web applications.

PHP 的缺点如下: - PHP 不适合用于大型基于内容的 Web 应用程序。
  • Since it is open-source, it is not secure. Because ASCII text files are easily available.
  • Change or modification in the core behavior of online applications is not allowed by PHP.
  • If we use more features of the PHP framework and tools, it will cause poor performance of online applications.
  • PHP features a poor quality of handling errors. PHP lacks debugging tools, which are needed to look for warnings and errors. It has only a few debugging tools in comparison to other programming languages.

247. You are given two non-empty linked lists that each represent a non-negative integer. The digits are kept in reverse order, with each node containing only one digit. Add the two numbers together and return the total as a linked list.

给定两个非空链表,每个链表表示一个非负整数。数字以相反顺序存储,每个节点仅包含一位数字。将两个数相加,并以链表形式返回总和。
  • 知识点: 后端 (标签: interviewbit, qualcomm, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: 高通
  • id: 69b37c2d58d557c902bb815b | 官方: 否 | 付费: 否

答案:

Except for the number 0 itself, you may presume that the two numbers do not have any leading zeros.

除了数字 0 本身之外,你可以假定这两个数字不含任何前导零。

Example 1:

示例1:
  • Input: l1 = [2,4,3], l2 = [5,6,4]
  • Output: [7,0,8]
  • Explanation: 342 + 465 = 807.

Example 2:

示例2:
  • Input: l1 = [0], l2 = [0]
  • Output: [0]

Example 3:

示例3:
  • Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
  • Output: [8,9,9,9,0,0,0,1]

The total may be used to maintain track of the carry bit; if the sum is greater than 10, sum / 10 will return 1 as two digits, and the carry bit cannot have a sum greater than 19. To construct the list, we utilise a double pointer to store the address of ListNode next in the ListNode structure for the list's tail. We must first dereference the tail because we are using a double pointer. So, tail will point to the memory address where the next node will be added, (tail) will be the address of the tail node (after memory has been allocated), and &(*tail)->next will be the address of the next ListNode in the tail node.

总和可用于跟踪进位位;如果和大于 10,则 sum / 10 将返回 1(作为两位数),且进位位的和不可能大于 19。为构建链表,我们使用双指针在 ListNode 结构中存储链表尾部的 ListNode next 的地址。由于我们使用的是双指针,必须先解引用 tail。因此,tail 将指向即将添加下一个节点的内存地址,(tail) 将是尾节点的地址(在分配内存之后),而 &(tail)->next 将是尾节点中下一个 ListNode 的地址。
class Solution {
class Solution {

public:

public:
ListNode addTwoNumbers(ListNode l1, ListNode* l2) {
ListNode addTwoNumbers(ListNode l1, ListNode* l2) {
int sum = 0;
int sum = 0;
ListNode dummy, **tail = &dummy.next;
ListNode dummy, **tail = &dummy.next;
while (l1 || l2 || sum) {
while (l1 || l2 || sum) {
if (l1) {
if (l1) {
sum += l1->val;
sum += l1->val;
l1 = l1->next;
l1 = l1->next;
}
if (l2) {
if (l2) {
sum += l2->val;
sum += l2->val;
l2 = l2->next;
l2 = l2->next;
}
(*tail) = new ListNode(sum % 10);
(*tail) = new ListNode(sum % 10);
tail = &(*tail)->next;
tail = &(*tail)->next;
sum /= 10;
sum /= 10;

}
return dummy.next;

return dummy.next;
}
};

248. What do you understand by RESTful Web Services?

你如何理解 RESTful Web 服务?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6581 | 官方: 否 | 付费: 否

答案:

RESTful web services are services that follow REST architecture. REST stands for Representational State Transfer and uses HTTP protocol (web protocol) for implementation. These services are lightweight, provide maintainability, scalability, support communication among multiple applications that are developed using different programming languages. They provide means of accessing resources present at server required for the client via the web browser by means of request headers, request body, response body, status codes, etc.

RESTful Web 服务是遵循 REST 架构的服务。REST 代表表述性状态转移,并使用 HTTP 协议(Web 协议)进行实现。这些服务轻量级,提供可维护性、可扩展性,支持使用不同编程语言开发的多个应用程序之间的通信。它们通过请求头、请求体、响应体、状态码等,提供通过 Web 浏览器访问服务器上供客户端所需资源的方式。

249. Define Messaging in terms of RESTful web services.

在 RESTful Web 服务中定义消息传递。
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6584 | 官方: 否 | 付费: 否

答案:

The technique of sending a message from the REST client to the REST server in the form of an HTTP request and the server responding back with the response as HTTP Response is called Messaging. The messages contained constitute the data and the metadata about the message.

将消息以HTTP请求的形式从REST客户端发送到REST服务器,服务器以HTTP响应形式回应,这一技术称为消息传递。所包含的消息构成了关于消息的数据和元数据。

250. Can you tell the disadvantages of RESTful web services?

你能告诉我RESTful Web服务的缺点吗?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6587 | 官方: 否 | 付费: 否

答案:

The disadvantages are: - As the services follow the idea of statelessness, it is not possible to maintain sessions. (Session simulation responsibility lies on the client-side to pass the session id)

缺点是:- 由于服务遵循无状态理念,无法维护会话。(会话模拟的责任在于客户端,需要传递会话ID)
  • REST does not impose security restrictions inherently. It inherits the security measures of the protocols implementing it. Hence, care must be chosen to implement security measures like integrating SSL/TLS based authentications, etc.

251. What are the HTTP Methods?

什么是HTTP方法?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc658a | 官方: 否 | 付费: 否

答案:

HTTP Methods are also known as HTTP Verbs. They form a major portion of uniform interface restriction followed by the REST that specifies what action has to be followed to get the requested resource. Below are some examples of HTTP Methods: - GET: This is used for fetching details from the server and is basically a read-only operation.

HTTP方法也称为HTTP动词。它们构成了REST遵循的统一接口限制的主要部分,该限制规定了获取请求资源所需采取的操作。以下是HTTP方法的一些示例:- GET:用于从服务器获取详细信息,基本上是只读操作。
  • POST: This method is used for the creation of new resources on the server.
  • PUT: This method is used to update the old/existing resource on the server or to replace the resource.
  • DELETE: This method is used to delete the resource on the server.
  • PATCH: This is used for modifying the resource on the server.
  • OPTIONS: This fetches the list of supported options of resources present on the server.
    The POST, GET, PUT, DELETE corresponds to the create, read, update, delete operations which are most commonly called CRUD Operations .

    POST、GET、PUT、DELETE分别对应创建、读取、更新、删除操作,这些操作通常称为CRUD操作。

GET, HEAD, OPTIONS are safe and idempotent methods whereas PUT and DELETE methods are only idempotent. POST and PATCH methods are neither safe nor idempotent.

GET、HEAD、OPTIONS是安全且幂等的方法,而PUT和DELETE方法仅幂等。POST和PATCH方法既不安全也不幂等。

252. What are HTTP Status codes?

什么是HTTP状态码?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc658d | 官方: 否 | 付费: 否

答案:

These are the standard codes that refer to the predefined status of the task at the server. Following are the status codes formats available: - 1xx - represents informational responses

这些是标准代码,指服务器上任务的预定义状态。以下是可用的状态码格式:- 1xx - 表示信息性响应
  • 2xx - represents successful responses
  • 3xx - represents redirects
  • 4xx - represents client errors
  • 5xx - represents server errors
    Most commonly used status codes are: - 200 - success/OK

    最常用的状态码是:- 200 - 成功/OK
  • 201 - CREATED - used in POST or PUT methods.
  • 304 - NOT MODIFIED - used in conditional GET requests to reduce the bandwidth use of the network. Here, the body of the response sent should be empty.
  • 400 - BAD REQUEST - This can be due to validation errors or missing input data.
  • 401- UNAUTHORIZED - This is returned when there is no valid authentication credentials sent along with the request.
  • 403 - FORBIDDEN - sent when the user does not have access (or is forbidden) to the resource.
  • 404 - NOT FOUND - Resource method is not available.
  • 500 - INTERNAL SERVER ERROR - server threw some exceptions while running the method.
  • 502 - BAD GATEWAY - Server was not able to get the response from another upstream server.

253. What do you understand by JAX-RS?

你对JAX-RS如何理解?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6590 | 官方: 否 | 付费: 否

答案:

As the name itself stands (JAX-RS= Java API for RESTful Web Services) is a Java-based specification defined by JEE for the implementation of RESTful services. The JAX-RS library makes usage of annotations from Java 5 onwards to simplify the process of web services development. The latest version is 3.0 which was released in June 2020. This specification also provides necessary support to create REST clients.

正如名称所示(JAX-RS = Java API for RESTful Web Services),是JEE定义的基于Java的规范,用于实现RESTful服务。JAX-RS库从Java 5起使用注解来简化Web服务开发过程。最新版本是3.0,于2020年6月发布。该规范还提供了创建REST客户端所需的支持。

254. What is the concept of statelessness in REST?

REST中的无状态概念是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6593 | 官方: 否 | 付费: 否

答案:

The REST architecture is designed in such a way that the client state is not maintained on the server. This is known as statelessness. The context is provided by the client to the server using which the server processes the client’s request. The session on the server is identified by the session identifier sent by the client.

REST架构设计为不在服务器上维护客户端状态,这被称为无状态。客户端向服务器提供上下文,服务器据此处理客户端的请求。服务器上的会话通过客户端发送的会话标识符来识别。

255. What are the features of RESTful Web Services?

RESTful Web服务的特性是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6596 | 官方: 否 | 付费: 否

答案:

Every RESTful web service has the following features: - The service is based on the Client-Server model.

每个RESTful Web服务都有以下特性:- 服务基于客户端-服务器模型。
  • The service uses HTTP Protocol for fetching data/resources, query execution, or any other functions.
  • The medium of communication between the client and server is called “Messaging”.
  • Resources are accessible to the service by means of URIs.
  • It follows the statelessness concept where the client request and response are not dependent on others and thereby provides total assurance of getting the required data.
  • These services also use the concept of caching to minimize the server calls for the same type of repeated requests.
  • These services can also use SOAP services as implementation protocol to REST architectural pattern.

256. What is URI?

什么是URI?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc6599 | 官方: 否 | 付费: 否

答案:

Uniform Resource Identifier is the full form of URI which is used for identifying each resource of the REST architecture. URI is of the format:

统一资源标识符是URI的全称,用于标识REST架构中的每个资源。URI的格式为:

:////

<协议>://<服务名>/<资源类型>/<资源ID>
There are 2 types of URI:
URI有两种类型:
  • URN: Uniform Resource Name identifies the resource by means of a name that is both unique and persistent.
    URN doesn’t always specify where to locate the resource on the internet. They are used as templates that are used by other parsers to identify the resource.

    URN并不总是指定资源在互联网上的位置。它们被用作模板,由其他解析器用来标识资源。
    These follow the urn scheme and usually prefixed with urn:. Examples include
    这些遵循URN方案,通常以urn:为前缀。例如包括:
    urn:isbn:1234567890 is used for identification of book based on the ISBN number in a library application.
    urn:isbn:1234567890 用于根据图书馆应用中的ISBN号标识书籍。

urn:mpeg:mpeg7:schema:2001 is the default namespace rules for metadata of MPEG-7 video.

urn:mpeg:mpeg7:schema:2001 是MPEG-7视频元数据的默认命名空间规则。

Whenever a URN identifies a document, they are easily translated into a URL by using “resolver” after which the document can be downloaded. - URL: Uniform Resource Locator has the information regarding fetching of a resource from its location.

当URN标识一个文档时,它们可以通过使用“解析器”轻松转换为URL,之后文档即可下载。- URL:统一资源定位符包含从其位置获取资源的信息。
Examples include: http://abc.com/samplePage.html ftp://sampleServer.com/sampleFile.zip file:///home/interviewbit/sampleFile.txt
例如包括:http://abc.com/samplePage.html ftp://sampleServer.com/sampleFile.zip file:///home/interviewbit/sampleFile.txt

URLs start with a protocol (like ftp, http etc) and they have the information of the network hostname (sampleServer.com) and the path to the document(/samplePage.html). It can also have query parameters.

URL以协议开头(如ftp、http等),它们包含网络主机名(sampleServer.com)和文档路径(/samplePage.html)的信息。它还可以包含查询参数。

257. What is a REST Resource?

什么是REST资源?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3558d557c902bc659c | 官方: 否 | 付费: 否

答案:

Every content in the REST architecture is considered a resource. The resource is analogous to the object in the object-oriented programming world. They can either be represented as text files, HTML pages, images, or any other dynamic data. - The REST Server provides access to these resources whereas the REST client consumes (accesses and modifies) these resources. Every resource is identified globally by means of a URI.

REST架构中的每个内容都被视为一个资源。资源类似于面向对象编程世界中的对象。它们可以表示为文本文件、HTML页面、图像或任何其他动态数据。- REST服务器提供对这些资源的访问,而REST客户端消费(访问和修改)这些资源。每个资源通过URI在全球范围内进行标识。

258. Explain Rails Migration.

解释Rails迁移。
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6701 | 官方: 否 | 付费: 否

答案:

A Rails migration is a tool for altering the database schema of an application. Instead of handling SQL scripts, you use a domain-specific language to define database modifications (DSL). Because the code is database-agnostic, you can quickly port your project to a different platform. Migrations can be rolled back and managed alongside your application source code.

Rails迁移是一种用于修改应用程序数据库模式的工具。您无需处理SQL脚本,而是使用领域特定语言来定义数据库修改(DSL)。由于代码与数据库无关,您可以快速将项目移植到不同平台。迁移可以回滚,并与应用程序源代码一起管理。

259. Explain the naming convention in Rails.

解释Rails中的命名约定。
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6705 | 官方: 否 | 付费: 否

答案:

  • Variables: All letters are lowercase, and words are separated by underscores.
  • Class and Modules: Mixed case, no underscore, each word starts with an uppercase.
  • Database Table: The database table name should have lowercase letters and underscore between words; all table names should be in the plural form.
  • Model: Mixed-case, always has singular with the table name.
  • Controller: Represented in plural form like OrdersController.

260. What is ORM(Object-Relationship-Model).

什么是ORM(对象-关系模型)。
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6708 | 官方: 否 | 付费: 否

答案:

In Rails, the ORM or Object Relationship Model indicates that your classes are mapped to the database table, and objects are directly mapped to the table rows. The attributes and relationships of objects in an application may be easily stored and retrieved from a database using ORM, which requires less overall database access code and does not require writing SQL queries directly.

在Rails中,ORM或对象关系模型表示你的类映射到数据库表,对象直接映射到表行。使用ORM可以轻松地从数据库存储和检索应用程序中对象的属性和关系,这需要更少的整体数据库访问代码,并且无需直接编写SQL查询。

261. What is the difference between false and nil in Ruby?

在Ruby中,false和nil之间有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc670b | 官方: 否 | 付费: 否

答案:

  • True and false are boolean values in Ruby that signify yes and no, respectively. True is a TrueClass object, and False is a FalseClass object.
  • Nil is a special value in Ruby that represents the lack of any value. Nil is a NilClass object. Nothing or void is referred to as nil in Ruby.

262. What is the difference between String and Symbol?

String和Symbol之间有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc670e | 官方: 否 | 付费: 否

答案:

Strings are any text typed between quote marks ("this is a string," "so is this," "this too!") and symbols are text that starts with a colon (: symbol). Strings and symbols, on the other hand, have diverse functions that make them valuable for different programming tasks.

字符串是任何在引号之间输入的文本(“这是一个字符串”,“这也是”,“这个也是!”),而符号是以冒号(: symbol)开头的文本。另一方面,字符串和符号具有不同的功能,使它们适用于不同的编程任务。

"Scalar value objects used as identifiers, mapping immutable strings to fixed internal values," according to the Ruby definition. This essentially indicates that symbols are immutable strings.

根据Ruby定义,“用作标识符的标量值对象,将不可变字符串映射到固定的内部值。”这基本上表明符号是不可变字符串。

263. What command can you use to create a controller for the subject?

可以使用什么命令为subject创建控制器?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6711 | 官方: 否 | 付费: 否

答案:

Use the following command to build a controller for the subject:

使用以下命令为subject构建控制器:

C:\ruby\library> ruby script/generate controller subject.

C:\ruby\library> ruby script/generate controller subject.

264. What do subdirectory app/controllers and app/helpers do?

子目录app/controllers和app/helpers有什么作用?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6714 | 官方: 否 | 付费: 否

答案:

  • apps/controller: The controller classes are found in the app/controllers subfolder, which Rails searches for. A user's web request is handled by a controller.
  • app/helpers: Any helper classes needed to assist the model, view, and controller classes are stored in the app/helpers subdirectory. This keeps the model, view, and controller code clean, simple, and focused.

265. What is a Rails Controller?

什么是Rails控制器?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6717 | 官方: 否 | 付费: 否

答案:

Your application's logical heart is the Rails controller. It orchestrates the user's interaction with the views and the model. A number of key ancillary functions are also housed in the controller, including: - It is in charge of directing external requests to internal processes.

你的应用程序的逻辑核心是Rails控制器。它协调用户与视图和模型的交互。控制器中还包含许多关键的辅助功能,包括:- 它负责将外部请求定向到内部进程。
  • It controls caching, which can improve application performance by orders of magnitude.
  • It handles helper modules, which add functionality to view templates without adding code to them.
  • It keeps track of sessions, creating the impression that users are still interacting with our apps.

266. What is Rails Active Record in Ruby on Rails?

在Ruby on Rails中,什么是Rails Active Record?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc671a | 官方: 否 | 付费: 否

答案:

The Object/Relational Mapping (ORM) layer included with Rails is called Active Record. It roughly resembles the conventional ORM model, which goes like this: - Tables correspond to classes.

Rails附带的Object/Relational Mapping(ORM)层称为Active Record。它大致类似于传统的ORM模型,如下所示:- 表对应于类。
  • Rows correspond to objects, and
  • The columns correspond to the attributes of the objects.
    Active Records in Rails provide a connection and interface between relational database tables and Ruby computer code that manipulates database records.

    Rails中的Active Records提供了关系数据库表和操作数据库记录的Ruby计算机代码之间的连接和接口。

267. What is Ruby on Rails?

什么是Ruby on Rails?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc671d | 官方: 否 | 付费: 否

答案:

  • Ruby is a high-level, interpreted programming language that supports a variety of programming paradigms.
  • Rails, on the other hand, is a framework that can be used to build web applications.

268. Explain how rail implements Ajax?

解释Rails如何实现Ajax?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6720 | 官方: 否 | 付费: 否

答案:

The way Rails supports Ajax operations is simple and consistent. Different user actions force the browser to display a new web page (like any regular web application) or initiate an Ajax activity after the original web page has been produced and displayed. - Some trigger is fired- This could be a user clicking on a button or link, a user changing data on a form or in a field, or just a recurring trigger (based on a timer).

Rails支持Ajax操作的方式简单且一致。不同的用户操作会促使浏览器显示一个新网页(就像任何常规的Web应用一样),或者在原始网页生成并显示后启动一次Ajax活动。- 某个触发器被触发- 这可能是用户点击按钮或链接、用户更改表单或字段中的数据,或者仅仅是基于定时器的周期性触发器。
  • The server is contacted by the web client- The XMLHttpRequest JavaScript function transmits data associated with the trigger to a server action handler. The data could be the checkbox ID, the text in an entry field, or the entire form.
  • The server performs the processing- The server-side action handler (Rails controller action) manipulates the data and sends an HTML fragment to the web client.
  • The HTML fragment is received by the client-side JavaScript- The client-side JavaScript which Rails generate automatically is used to alter a specific area of the current page's HTML, usually the content of an element.

269. What command is used to create a migration?

创建迁移使用什么命令?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6723 | 官方: 否 | 付费: 否

答案:

To create migration command includes:

创建迁移的命令包括:

C:\ruby\application>ruby script/generate migration table_name

C:\ruby\application>ruby script/generate migration table_name

270. What does garbage collection do in Ruby on Rails?

Ruby on Rails中的垃圾收集是做什么的?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6726 | 官方: 否 | 付费: 否

答案:

Garbage collection is a technique for controlling the amount of memory used by computer programs. Garbage collection and other memory management techniques, like reference counting, work by having the language keep track of which objects are in use by a program rather than the developer. This allows the programmer to concentrate on the business logic or other challenge at hand rather than the intricacies of memory allocation and release. This also aids program stability and security, as improper memory management can cause crashes, and memory management bugs account for a major fraction of security bugs.

垃圾收集是一种控制计算机程序所用内存量的技术。垃圾收集和其他内存管理技术(如引用计数)通过让语言跟踪程序中正在使用的对象来工作,而不是由开发者来跟踪。这使得程序员可以专注于业务逻辑或手头的其他挑战,而不是内存分配和释放的复杂性。这也有助于程序的稳定性和安全性,因为不当的内存管理可能导致崩溃,而内存管理错误占了安全漏洞的很大一部分。

271. Explain Cross-Site Request Forgery (CSRF). How is Rails protected against it?

解释跨站请求伪造(CSRF)。Rails如何防范它?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6729 | 官方: 否 | 付费: 否

答案:

Cross-Site Request Forgery (CSRF) is a typical online application attack that compromises a victim's authenticated session. This attack entails duping a target into executing unwanted actions on a website to which they have been authenticated.

跨站请求伪造(CSRF)是一种典型的在线应用攻击,它会破坏受害者的已认证会话。这种攻击涉及诱骗目标在其已通过认证的网站上执行未经请求的操作。

You must add "protect from forgery" to your ApplicationController to protect against CSRF attacks. Rails will now require a CSRF token in order to complete the request. Every form built using Rails forms builders includes a hidden field called CSRF token.

您必须在ApplicationController中添加“protect_from_forgery”来防范CSRF攻击。Rails将要求请求包含CSRF令牌才能完成。使用Rails表单构建器创建的每个表单都包含一个名为CSRF令牌的隐藏字段。

272. How to define Instance Variable, Global Variable, and Class Variable in Ruby?

如何在Ruby中定义实例变量、全局变量和类变量?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc672c | 官方: 否 | 付费: 否

答案:

  • Instance Variable in Ruby begins with– @
  • Class variable in Ruby begins with– @@
  • The global variable in Ruby begins with– $

273. What is the role of load and require in Ruby?

在Ruby中,load和require的作用是什么?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc672f | 官方: 否 | 付费: 否

答案:

  • load( )- We use load to execute code.
  • require( )- We use require to import libraries.

274. What are access modifiers in Ruby?

Ruby中的访问修饰符是什么?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6732 | 官方: 否 | 付费: 否

答案:

  • Public: In this, all members are available to everyone to modify.
  • Private: In this, only functions inside the class can access members.

    1. 私有(Private):在这种情况下,只有类内部的函数可以访问成员。
  • Protected: In this, the members can only be accessed by functions inside the subclass.

    1. 受保护(Protected):在这种情况下,成员只能被子类内部的函数访问。

275. What is MVC and how does it work?

什么是MVC,它是如何工作的?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6735 | 官方: 否 | 付费: 否

答案:

The Model-View-Controller (MVC) architectural pattern divides an application into three logical components: model, view, and controller. Each of these components is designed to handle specific parts of application development.

模型-视图-控制器(MVC)架构模式将应用程序划分为三个逻辑组件:模型、视图和控制器。这些组件中的每一个都设计用于处理应用程序开发的特定部分。

The request initially goes to the controller, who then chooses a suitable view and interacts with the model, who then interacts with your database and sends the response to the controller, who then gives the output parameter to the view based on the response.

请求最初到达控制器,控制器随后选择合适的视图并与模型交互,模型再与数据库交互并将响应发送给控制器,控制器随后根据响应将输出参数提供给视图。

276. How will you delete a node in a doubly-linked list (DLL)?

你将如何删除双向链表(DLL)中的一个节点?
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, siemens, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Siemens
  • id: 69b37c5158d557c902bc75be | 官方: 否 | 付费: 否

答案:

The following is the process to delete a node in a doubly-linked list (DLL): - Step 1: Create a function that takes as arguments a linked list and a node that needs to be deleted, and deletes the node.

以下是删除双向链表(DLL)中一个节点的过程:- 步骤1:创建一个函数,其参数为一个链表和一个需要删除的节点,并删除该节点。
  • Step 2: To delete a head node:
    Move the head pointer to the next node in the current node (head here). Set the previous pointer of the next node to the previous pointer of the current node. - Step 3: If you wish to remove the centre node, follow these steps.

    将头指针移动到当前节点(这里的head)的下一个节点。将下一个节点的前驱指针设置为当前节点的前驱指针。- 步骤3:如果你希望删除中间节点,请遵循以下步骤。
    Set the previous pointer of the next node to the previous pointer of the current node. Move the previous node's next pointer to the current node's next pointer. Remove the node. (the most recent node) You do not need to delete previous or next if they are NULL. (for removing the final node) - Step 4: Call the function on the given linked list and specify the node you want to delete.
    将下一个节点的前驱指针设置为当前节点的前驱指针。将前一个节点的后继指针移动到当前节点的后继指针。删除该节点。(最近的节点)如果前驱或后继为NULL,则不需要删除它们。(用于删除最后一个节点)- 步骤4:在给定的链表上调用该函数,并指定你要删除的节点。
    Code to delete a node in a doubly-linked list:
    删除双向链表中一个节点的代码:

import gc

import gc

Node of the doubly linked list

class Node:

class Node:

def __init__(self, data):

def __init__(self, data):
self.data = data
self.data = data
self.next = None
self.next = None
self.prev = None
self.prev = None

class DoublyLinkedList:

class DoublyLinkedList:

def __init__(self):

def __init__(self):
self.head = None
self.head = None

A function to delete a node in a Doubly Linked List.

def deleteNode(self, todelete):

def deleteNode(self, todelete):

if self.head is None or todelete is None:

if self.head is None or todelete is None:
return
return

If node to be deleted is the head node

if self.head == todelete:

if self.head == todelete:
self.head = todelete.next
self.head = todelete.next

Change next only if node to be deleted is NOT

the last node

if todelete.next is not None:

if todelete.next is not None:
todelete.next.prev = todelete.prev
todelete.next.prev = todelete.prev

Change prev only if node to be deleted is NOT

the first node

if todelete.prev is not None:

if todelete.prev is not None:
todelete.prev.next = todelete.next
todelete.prev.next = todelete.next

gc.collect()

gc.collect()

Given a reference to the head of a list and an

integer, inserts a new node on the front of list

def push(self, new_data):

def push(self, new_data):

Allocates node and inserts the data in it

new_node = Node(new_data)

new_node = Node(new_data)

Make next of new node as head and previous as None

new_node.next = self.head

new_node.next = self.head

Change prev of head node to new_node

if self.head is not None:

如果 self.head 不是 None:
self.head.prev = new_node
self.head.prev = new_node

Move the head to point to the new node

self.head = new_node

self.head = new_node

def printList(self, node):

def printList(self, node):
while(node is not None):
while(node is not None):
print(node.data,end=' ')
print(node.data,end=' ')
node = node.next
node = node.next

Start with an empty list

dll = DoublyLinkedList()

dll = DoublyLinkedList()

dll.push(2);

dll.push(2);
dll.push(4);
dll.push(4);
dll.push(8);
dll.push(8);
dll.push(10);
dll.push(10);

print ("\n The original linked list",end=' ')

print ("\n 原始链表",end=' ')
dll.printList(dll.head)
dll.printList(dll.head)

delete nodes from doubly linked list

dll.deleteNode(dll.head)

dll.deleteNode(dll.head)
dll.deleteNode(dll.head.next)
dll.deleteNode(dll.head.next)
dll.deleteNode(dll.head.next)
dll.deleteNode(dll.head.next)

Updated linked list will be NULL<-8->NULL

print("\n The updated linked list",end=' ')

print("\n 更新后的链表",end=' ')
dll.printList(dll.head)
dll.printList(dll.head)
Useful Resources:
有用资源:
  • Networking Interview
  • Data Structure Interview
  • Algorithm Interview
  • Compilers
  • Interview Resources

277. What are the essential features of Sitecore?

Sitecore 的基本功能有哪些?
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7649 | 官方: 否 | 付费: 否

答案:

In order to help you better understand the benefits of Sitecore, here are some of the platform key features: - Personalized Customer Data: Everything about customers, from their interactions to behaviours to data, is tracked and stored in order to provide insights to help the team deepen engagement and increase revenue.

为了帮助您更好地理解 Sitecore 的优势,以下是该平台的一些关键功能:- 个性化客户数据:有关客户的一切信息,从互动到行为再到数据,均被跟踪和存储,以提供洞察力,帮助团队加深参与度并增加收入。
  • Sitecore Experience Database (xDB): By integrating all of your customer experience data (including data from CRM and non-Sitecore-based systems), the Sitecore xDB creates a single store for the entire experience. Finally, you can see the entire journey of every individual customer all in one place (single repository).
  • Sitecore Experience Profile (xP): When xDB collects customer experience data, Sitecore XP creates an individual profile of each customer. The information in these profiles will help you to better understand your customers, such as what products they buy, what they click on, and how long they spend on your website.
  • Multi-language and Multi-Site Content Support: Expanding globally brings many challenges, but delivering a consistent brand experience to new customers and employees is among the most crucial. Sitecore provides multilingual support to help you reduce your time-to-market and stay competitive, wherever you are.
  • Marketing automation: Marketers can easily build automation campaigns that deliver real-time, automated responses in response to the actions visitors take on a site. For example, when a customer completes a purchase, an automated response email expressing appreciation for the purchase is sent.
  • Sitecore Federated Experience Manager (FXM): Wouldn't it be great if you didn't have to switch all your websites to Sitecore? Sitecore FXM lets you extend certain Sitecore features to non-Sitecore sites, ensuring that your customers have a seamless, positive experience across all of your websites (and ensuring accurate customer data is captured).

278. How to add SXA into Sitecore?

如何将 SXA 添加到 Sitecore?
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc764c | 官方: 否 | 付费: 否

答案:

First, you need to deploy the Sitecore Experience Platform on your on-premises content management system before installing the Sitecore Experience Accelerator (SXA). You can then go to the Sitecore Downloads page and download the SXA package that corresponds with the version of the Sitecore Experience Platform you are using.

首先,您需要在本地内容管理系统上部署 Sitecore 体验平台,然后再安装 Sitecore 体验加速器(SXA)。然后,您可以前往 Sitecore 下载页面,下载与您使用的 Sitecore 体验平台版本相对应的 SXA 包。

279. What is SXA (Sitecore Experience Accelerator)?

什么是 SXA(Sitecore 体验加速器)?
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc764f | 官方: 否 | 付费: 否

答案:

The Sitecore Experience Accelerator (SXA) is a tool that enables web development teams to develop websites faster and reuse components, templates, and layouts across multiple sites. SXA basically separates structure and design, which enables frontend/backend developers, content authors, and creative designers to work simultaneously, and you can deploy and maintain multiple sites efficiently and cost-effectively. After the user experience plan has been developed, everyone can get started on the platform. As an example: while the front-end developer is working on the theme, the content author enters content into the wireframe environment. Meanwhile, the developer sets up the data templates.

Sitecore 体验加速器(SXA)是一种工具,使 Web 开发团队能够更快地开发网站,并在多个站点之间重用组件、模板和布局。SXA 基本上分离了结构和设计,使前端/后端开发人员、内容作者和创意设计师能够同时工作,并且您可以高效且经济地部署和维护多个站点。在用户体验计划制定后,每个人都可以开始在平台上工作。例如:当前端开发人员处理主题时,内容作者在线框环境中输入内容。同时,开发人员设置数据模板。

280. Explain what you mean by Solr in Sitecore.

解释您在 Sitecore 中所说的 Solr 是什么意思。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7652 | 官方: 否 | 付费: 否

答案:

In essence, Sitecore Solr is primarily an indexing technology. Sitecore basically offers two search engines, Lucene and Solr, that can be used to search Sitecore's content databases as well as the operational databases used to gather analytics data, test data, and more. Solr can also be used for the following reasons: - Solr performs better when indexing large quantities of items (50,000 and above).

本质上,Sitecore Solr 主要是一种索引技术。Sitecore 基本上提供两种搜索引擎:Lucene 和 Solr,可用于搜索 Sitecore 的内容数据库以及用于收集分析数据、测试数据等的操作数据库。Solr 也可用于以下原因:- 在索引大量项目(50,000 及以上)时,Solr 性能更好。
  • Solr has more robust capabilities. Solr is recommended if the search is the primary interface for your site.

281. Explain how to implement Sitecore.

解释如何实现 Sitecore。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7655 | 官方: 否 | 付费: 否

答案:

Sitecore CMS is based on .NET technology. Comparatively, Sitecore is better than a large number of other .NET-based platforms, such as OpenText or Sharepoint. Like any software implementation, Sitecore implementation can also be time-consuming and expensive. However, it doesn't have to be complex. The following are some key points as part of the implementation process. - Identify Implementation Type: A CMS implementation may involve a complete redesign or maybe more of a re-platforming. It is beneficial to meet with your stakeholders before implementing to determine what is best for your business.

Sitecore CMS 基于 .NET 技术。相比之下,Sitecore 优于许多其他基于 .NET 的平台,例如 OpenText 或 Sharepoint。与任何软件实施一样,Sitecore 实施也可能耗时且昂贵。然而,它不一定是复杂的。以下是实施过程中的一些关键点。- 确定实施类型:CMS 实施可能涉及完全重新设计,或者可能更多是重新平台化。在实施之前,与您的利益相关者会面以确定最适合您业务的方式是有益的。
  • Prepare Implementation Document: As every Sitecore implementation is unique, you should create an architecture document that outlines your requirements and provides stakeholders with an overview of the project. This will prevent any unpleasant surprises in the future.
  • Set up a timeline: If you want your Sitecore implementation to succeed, you need to set a timeline. This will give you a rough estimate of how long the project will take and will also help you plan for any downtime that may occur.
  • Outline Expectations: Together with a timeline, you can outline what to expect during the implementation process. Using a CMS like Sitecore won't instantly solve all of your business's problems and it also doesn't mean you can use all of its features. The most valuable thing you can do when you start is to know what to expect and what limitations you might face.
  • Be aware of Costs: Costs can be high when implementing Sitecore. It is essential that you have a clear understanding of the project costs as well as the features and functions that are most important to your business.
  • Implementation Process: Finally, your implementation partner will walk you through the entire implementation process. In addition to the timeline and costs, any additional resources and personnel required will also be considered. In addition, it will outline the steps that will be taken by teams working together and which project management style will be used to implement the changes, either waterfall or agile, or any other.

282. Explain standard values in Sitecore.

解释 Sitecore 中的标准值。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7658 | 官方: 否 | 付费: 否

答案:

Data template fields have default values known as Standard Values. In Sitecore, a standard value is a way to specify a default value for a field, so that whenever items are created, it is possible to specify a field value that must be used by default. The standard values associated with each data template are stored in a child item of the data template definition item called "Standard Values". Whenever the value of a field for an item is NULL, standard values are used.

数据模板字段具有称为标准值的默认值。在 Sitecore 中,标准值是一种为字段指定默认值的方法,以便在创建项目时,可以指定必须默认使用的字段值。与每个数据模板关联的标准值存储在数据模板定义项目的子项目中,称为“标准值”。每当项目的字段值为 NULL 时,就会使用标准值。

As you can see in the above image, the "Sample item" data template basically contains the "Data" data template section definition item. The standard value of the "Sample" data template is stored as a child of the "Data" data template definition item named "_Standard Values."

如您在上图中所见,“示例项目”数据模板基本上包含“数据”数据模板部分定义项目。“示例”数据模板的标准值存储为“数据”数据模板定义项目的子项目,名为“_标准值”。

283. State difference between AEM (Adobe Experience Manager) and Sitecore.

说明 AEM(Adobe Experience Manager)和 Sitecore 之间的区别。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc765b | 官方: 否 | 付费: 否

答案:

AEM ( Adobe Experience Manager ) and Sitecore are two of the most popular enterprise-level CMS (Content management systems). Below are some key differences between Sitecore and AEM that will help you determine which is best for your business.

AEM(Adobe Experience Manager)和Sitecore是两个最流行的企业级CMS(内容管理系统)。以下是Sitecore和AEM之间的一些关键区别,将帮助您确定哪个最适合您的业务。

AEM vs Sitecore:

AEM与Sitecore对比:
AEMSitecore
With 9 different product offerings, AEM has separated several marketing features like analytics and campaigns into separate "products" for purchase. This is great for those who just need one feature, for example, Adobe Analytics, but if you want the full marketing package from Adobe, you have to buy those features separately rather than as part of one package.
AEM提供9种不同产品,已将分析和营销活动等多项营销功能分离为单独的“产品”供购买。这对于只需要单一功能(如Adobe Analytics)的用户来说非常棒,但如果您想要Adobe的完整营销套餐,则必须单独购买这些功能,而不是作为整体套餐的一部分。
There are four different products offered by Sitecore under the "Sitecore Experience Cloud". Only offering four platforms is wonderful because it packages up features so that they do not need to be acquired separately, and it also saves time and resources in configuring all the platforms to work together.
Sitecore在“Sitecore Experience Cloud”下提供四种不同产品。仅提供四个平台非常出色,因为它将功能打包在一起,无需单独获取,并且节省了配置所有平台协同工作所需的时间和资源。
With Adobe having acquired a number of different systems, Adobe Experience Cloud is comprised of different languages and databases. From a development standpoint, this is challenging since developers are likely to encounter issues while trying to build across multiple platforms and languages. Development for Adobe can therefore be more time consuming, costly, and complex.
由于Adobe收购了多个不同系统,Adobe Experience Cloud由多种语言和数据库组成。从开发角度来看,这具有挑战性,因为开发人员在跨多个平台和语言构建时可能会遇到问题。因此,Adobe的开发可能更耗时、更昂贵且更复杂。
All of Sitecore's products are built on top of the ASP.NET framework. It is easier, flexible, and more cost-effective to develop on Sitecore, and having .NET expertise is sufficient to develop across all platforms.
Sitecore的所有产品都基于ASP.NET框架构建。在Sitecore上开发更容易、更灵活且更具成本效益,拥有.NET专业知识足以在所有平台上进行开发。
Adobe's community and partner network are significantly less developed than Sitecore's and do not actively encourage community participation.
Adobe的社区和合作伙伴网络远不如Sitecore发达,且不积极鼓励社区参与。
As a result of its active and large partner network, Sitecore users are rewarded for their contributions to the Sitecore community through incentives and discounts.
由于其活跃且庞大的合作伙伴网络,Sitecore用户因对Sitecore社区的贡献而获得激励和折扣奖励。

284. Explain Helix and Habitat.

解释Helix和Habitat。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc765e | 官方: 否 | 付费: 否

答案:

  • Sitecore Helix: It is a set of guidelines and recommendations that govern the development of Sitecore websites. Essentially, Helix describes the overall architecture of your Sitecore solution and explains design principles that are versatile and adaptable to any Sitecore project. It mainly focuses on reducing dependencies between software modules, how they should be structured, and how individual sites can use them. Helix is a set of recommendations meant to make building, testing, extending, and maintaining a Sitecore project as easy as possible.
  • Habitat: This is a working Sitecore project built on the Sitecore Experience Platform utilizing Helix design principles and recommendations. The project serves as an example and shows how Helix's principles are applied, and allows developers to experience a project that is aligned with these principles. In addition, it saves the developer from having to create modules from scratch, as well as provides an excellent basis for developing additional modules and extending existing ones.

285. State difference between Sitecore and Drupal.

说明Sitecore和Drupal之间的区别。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7661 | 官方: 否 | 付费: 否

答案:

Sitecore and Drupal are incredibly powerful content management systems (CMS), but each has unique features/functionalities that are better suited to different types of businesses.

Sitecore和Drupal是极其强大的内容管理系统(CMS),但每个系统都有独特的特性/功能,更适合不同类型的业务。

Drupal vs Sitecore:

Drupal与Sitecore对比:
DrupalSitecore
This is an open-source platform and free to use.
这是一个开源平台,可免费使用。
This is a closed-source platform and a license is required to use it.
这是一个闭源平台,需要许可证才能使用。
Some of the world's largest and most complex websites are powered by Drupal, and the platform is an excellent choice for organizations looking for seamless integration.
世界上一些最大、最复杂的网站由Drupal提供支持,该平台是寻求无缝集成的组织的绝佳选择。
For organizations that are serious about journey orchestration, marketing, and content personalization, this platform is ideal.
对于重视旅程编排、营销和内容个性化的组织来说,该平台是理想选择。
It offers better scalability and performance. A number of modules are included to assist with database optimization, caching optimization, and handling errors on the website.
它提供更好的可扩展性和性能。包含许多模块,用于协助数据库优化、缓存优化和处理网站错误。
Performance and scalability are a challenge for Sitecore, but the company has managed to overcome them in recent large-scale deployments.
性能和可扩展性是Sitecore的挑战,但该公司最近在大规模部署中已成功克服了这些挑战。
Using Drupal as a content management system offers better features out-of-the-box, such as support for WAI-ARIA (Web Accessibility Initiative - Accessible Rich Internet Applications).
使用Drupal作为内容管理系统可提供更好的开箱即用功能,例如支持WAI-ARIA(Web无障碍倡议-无障碍富互联网应用)。
It offers relatively fewer features of web accessibility as compared to Drupal.
与Drupal相比,它提供的网页无障碍功能相对较少。

286. What do you mean by templates and write different types of templates in Sitecore?

模板是什么意思?写出Sitecore中不同类型的模板。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7664 | 官方: 否 | 付费: 否

答案:

Templates essentially provide a schema for content, and schema gives definition and structure to content. Generally, templates are items that provide structure and behaviour for other items. The following types of templates are available in Sitecore for different purposes: - Data Templates: These are used to specify how data should be entered. Specifically, they determine which field sections, field types, and field names should be included in each item.

模板本质上提供内容模式,而模式为内容提供定义和结构。通常,模板是为其他项目提供结构和行为的项目。Sitecore中提供以下类型的模板用于不同目的:- 数据模板:这些用于指定数据的输入方式。具体来说,它们确定每个项目应包含哪些字段节、字段类型和字段名称。
  • Branch Templates: This allows you to create a set of items instead of just one. Each branch template contains a branch template definition item, which can consist of a single item, a hierarchy of items, or multiple hierarchies of items.
  • Command Template: You can insert items through logic rather than by using a predefined structure. The data template and branch template use predefined structures, but command templates refer to Sitecore UI commands that invoke wizards or logic to create new items.

287. List the databases associated with Sitecore.

列出与Sitecore关联的数据库。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7667 | 官方: 否 | 付费: 否

答案:

Sitecore CMS utilizes three SQL Server databases listed below: - Core: This database contains all Sitecore settings, such as a large configuration file for the Sitecore UI. When customizing Sitecore, such as when adding applications to the Sitecore desktop, it can be used.

Sitecore CMS使用以下列出的三个SQL Server数据库:- Core:此数据库包含所有Sitecore设置,例如Sitecore UI的大型配置文件。在自定义Sitecore时(例如向Sitecore桌面添加应用程序时),可以使用它。
  • Master: All versions of the content are stored in this database. Here, business users edit/modify the content.
  • Web: Here you can find the most recent or latest version of published content that has reached the final stages of its workflow.

288. State the difference between WordPress and Sitecore.

说明WordPress和Sitecore之间的区别。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc766a | 官方: 否 | 付费: 否

答案:

WordPress and Sitecore are popular content management systems (CMS), but each has unique features/functionalities that are better suited to different types of businesses.

WordPress和Sitecore是流行的内容管理系统(CMS),但每个系统都有独特的特性/功能,更适合不同类型的业务。

WordPress vs Sitecore:

WordPress与Sitecore对比:
WordPressSitecore
WordPress offers thousands of plugins, themes, and customizations to choose from, which makes it an unmatched platform for flexibility.
WordPress提供数千种插件、主题和自定义选项可供选择,使其成为灵活性方面无与伦比的平台。
In terms of flexibility, Sitecore is more rigid than other CMS platforms.
在灵活性方面,Sitecore比其他CMS平台更死板。
WordPress doesn't have great security features built-in.
WordPress没有内置强大的安全功能。
This CMS platform comes with advanced security features by default. It is well-known that top security-sensitive organizations, such as those in banking, finance, government, etc., are proof of this.
此CMS平台默认带有高级安全功能。众所周知,银行、金融、政府等高度敏感的安全组织就是证明。
As of right now, WordPress does not include great features for scalability. However, by using third-party integrations and plugins, you have almost limitless options for scalability on your WordPress website.
截至目前,WordPress不包含出色的可扩展性功能。然而,通过使用第三方集成和插件,您几乎可以在WordPress网站上拥有无限的可扩展性选项。
Sitecore has a reputation for handling massive traffic spikes for top websites without any glitches, so it's higher in terms of scalability.
Sitecore以处理顶级网站的巨大流量高峰而无任何故障而著称,因此在可扩展性方面更高。
This is an open-source platform.
这是一个开源平台。
A license is required to use Sitecore. This means that Sitecore is closed-source.
使用Sitecore需要许可证。这意味着Sitecore是闭源的。
WordPress does not offer much marketing support. For basic marketing functions, it uses third-party tools, and some significant integrations will require development support.
WordPress不提供太多营销支持。对于基本营销功能,它使用第三方工具,一些重要的集成将需要开发支持。
For out-of-the-box solutions, Sitecore comes with an Experience Accelerator. Custom solutions, however, require custom development. You might consider Sitecore if your business needs a custom solution, and you are patient enough to wait for it to be built.
对于开箱即用的解决方案,Sitecore配有Experience Accelerator。然而,自定义解决方案需要自定义开发。如果您的业务需要自定义解决方案,并且您有足够的耐心等待其构建完成,则可以考虑Sitecore。
With cloud-based hosting and ready-to-use themes, WordPress has become easy to use and quick to get up and running. However, its ready-to-use themes are typically simple, generic, and not designed for marketing purposes.
借助基于云的托管和现成主题,WordPress变得易于使用且快速启动。然而,其现成主题通常简单、通用,且并非为营销目的而设计。
Sitecore is well-equipped to handle various digital marketing needs. It has superior marketing features including content personalization which improves UX and influences conversions. Other relevant marketing tools help with testing, eCommerce, and email marketing.
Sitecore具备处理各种数字营销需求的良好能力。它拥有卓越的营销功能,包括内容个性化,可改善用户体验并影响转化率。其他相关营销工具有助于测试、电子商务和电子邮件营销。

289. The sea watchtower picture appears at Sitecore sign in/log in. What does it mean?

海洋瞭望塔图片出现在Sitecore登录界面中。它是什么意思?
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc766d | 官方: 否 | 付费: 否

答案:

The sea watchtower picture shows up because you are logged into the Desktop (the developer tool) rather than the Content Editor (the editor tool). Click the button labelled "Sitecore" in the lower/bottom left corner of the screen and click "Log Off". This will take you back to the Sitecore login screen. You can now login as usual: click the "Content Editor" button and enter your login information. Then click the "Login" button.

显示海洋瞭望塔图片是因为您登录的是桌面(开发工具)而非内容编辑器(编辑工具)。点击屏幕左下角的“Sitecore”按钮,然后点击“注销”。这将使您返回到Sitecore登录界面。您现在可以照常登录:点击“内容编辑器”按钮并输入您的登录信息。然后点击“登录”按钮。

290. What do you mean by Content Editor?

内容编辑器是什么意思?
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7670 | 官方: 否 | 付费: 否

答案:

All of the content on your website can be managed and edited using the Content Editor (CE). User roles, local security settings, and any customizations on a Sitecore installation can influence the appearance and functionality of the Content Editor. CE user interface generally consists of three main sections or areas that can be customized according to your preferences. These are - Ribbon: The area where you can access all the features of the Content Editor.

您网站上的所有内容都可以使用内容编辑器(CE)进行管理和编辑。用户角色、本地安全设置以及Sitecore安装上的任何自定义项都可能影响内容编辑器的外观和功能。CE用户界面通常由三个主要部分或区域组成,这些部分可以根据您的偏好进行自定义。它们是——功能区:您可以访问内容编辑器所有功能的区域。
  • Content Tree: An area in which all items are arranged and organized. All items within your Sitecore installation are displayed in the Content Tree.
  • Content Area: This is where you can edit or make changes to your items.

291. Explain the term “item” in Sitecore.

请解释Sitecore中“条目”这一术语。
  • 知识点: 后端 (主题: sitecore, cms;标签: interviewbit, sitecore, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5258d557c902bc7673 | 官方: 否 | 付费: 否

答案:

In Sitecore, an item represents any kind of information that makes up a webpage, including text, layouts, media files, and so on. Every item has a name, a unique ID (Identity), and a template defining the fields the item contains. Additionally, items may have multiple language versions. To edit, create, and insert items, you can use either the Content Editor (for managing and editing items on the website) or the Experience Editor (for editing items visible on the web page). Before you can edit an item in the Content Editor or Experience Editor, it must be in the editing state. If you want to ensure that no other content authors work on the same item simultaneously, you can lock the item before you begin.

在Sitecore中,条目代表构成网页的任何类型的信息,包括文本、布局、媒体文件等。每个条目都有一个名称、一个唯一ID(身份标识),以及一个定义条目包含字段的模板。此外,条目可能有多种语言版本。要编辑、创建和插入条目,您可以使用内容编辑器(用于管理和编辑网站上的条目)或体验编辑器(用于编辑网页上可见的条目)。在您能在内容编辑器或体验编辑器中编辑条目之前,该条目必须处于编辑状态。如果您想确保没有其他内容作者同时处理同一条目,您可以在开始之前锁定该条目。

292. What are the advantages of using Spring Boot?

使用Spring Boot有哪些优势?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a9e | 官方: 否 | 付费: 否

答案:

The advantages of Spring Boot are listed below: - Easy to understand and develop spring applications.

Spring Boot的优势如下:- 易于理解和开发Spring应用程序。
  • Spring Boot is nothing but an existing framework with the addition of an embedded HTTP server and annotation configuration which makes it easier to understand and faster the process of development.
  • Increases productivity and reduces development time.
  • Minimum configuration.
  • We don’t need to write any XML configuration, only a few annotations are required to do the configuration.

293. What are the Spring Boot key components?

Spring Boot的关键组件有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7aa1 | 官方: 否 | 付费: 否

答案:

Below are the four key components of spring-boot: - Spring Boot auto-configuration.

以下是Spring Boot的四个关键组件:- Spring Boot自动配置。
  • Spring Boot CLI.
  • Spring Boot starter POMs.
  • Spring Boot Actuators.

294. Why Spring Boot over Spring?

为什么选择Spring Boot而不是Spring?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7aa8 | 官方: 否 | 付费: 否

答案:

Below are some key points which spring boot offers but spring doesn’t: - Starter POM.

以下是Spring Boot提供而Spring不提供的一些关键点:- 启动器POM。
  • Version Management.
  • Auto Configuration.
  • Component Scanning.
  • Embedded server.
  • InMemory DB.
  • Actuators
    Spring Boot simplifies the spring feature for the user:

    Spring Boot简化了用户的Spring功能:

Spring vs Spring Boot

Spring与Spring Boot对比

295. What is the starter dependency of the Spring boot module?

Spring Boot模块的启动器依赖是什么?
  • 知识点: 后端 / 编程语言基础 / 行为与软技能 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7aab | 官方: 否 | 付费: 否

答案:

Spring boot provides numbers of starter dependency, here are the most commonly used - - Data JPA starter.

Spring Boot提供了许多启动器依赖,以下是最常用的——- 数据JPA启动器。
  • Test Starter.
  • Security starter.
  • Web starter.
  • Mail starter.
  • Thymeleaf starter.

296. How does Spring Boot works?

Spring Boot 如何工作?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7aae | 官方: 否 | 付费: 否

答案:

Spring Boot automatically configures your application based on the dependencies you have added to the project by using annotation. The entry point of the spring boot application is the class that contains @SpringBootApplication annotation and the main method.

Spring Boot 会根据你通过注解添加到项目中的依赖自动配置你的应用程序。Spring Boot 应用程序的入口点是包含 @SpringBootApplication 注解和 main 方法的类。

Spring Boot automatically scans all the components included in the project by using @ComponentScan annotation.

Spring Boot 使用 @ComponentScan 注解自动扫描项目中包含的所有组件。

297. What does the @SpringBootApplication annotation do internally?

@SpringBootApplication 注解在内部做了什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ab2 | 官方: 否 | 付费: 否

答案:

The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScan with their default attributes. Spring Boot enables the developer to use a single annotation instead of using multiple. But, as we know, Spring provided loosely coupled features that we can use for each annotation as per our project needs.

@SpringBootApplication 注解等同于使用具有默认属性的 @Configuration、@EnableAutoConfiguration 和 @ComponentScan。Spring Boot 使开发人员能够使用单个注解,而不是使用多个注解。但正如我们所知,Spring 提供了松散耦合的特性,我们可以根据项目需求为每个注解分别使用。

298. What is the purpose of using @ComponentScan in the class files?

在类文件中使用 @ComponentScan 的目的是什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ab5 | 官方: 否 | 付费: 否

答案:

Spring Boot application scans all the beans and package declarations when the application initializes. You need to add the @ComponentScan annotation for your class file to scan your components added to your project.

Spring Boot 应用程序在初始化时会扫描所有 Bean 和包声明。你需要为你的类文件添加 @ComponentScan 注解,以扫描你添加到项目中的组件。

299. How does a spring boot application get started?

Spring Boot 应用程序如何启动?
  • 知识点: 后端 / 编程语言基础 / 行为与软技能 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ab8 | 官方: 否 | 付费: 否

答案:

Just like any other Java program, a Spring Boot application must have a main method. This method serves as an entry point, which invokes the SpringApplication#run method to bootstrap the application.

与任何其他 Java 程序一样,Spring Boot 应用程序必须有一个 main 方法。此方法作为入口点,调用 SpringApplication#run 方法来引导应用程序。

@SpringBootApplication

@SpringBootApplication
public class MyApplication {
public class MyApplication {

public static void main(String[] args) {

public static void main(String[] args) {

SpringApplication.run(MyApplication.class);

SpringApplication.run(MyApplication.class);
// other statements
// 其他语句
}
}

300. What are starter dependencies?

什么是 starter 依赖?
  • 知识点: 后端 / 编程语言基础 / 行为与软技能 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7abb | 官方: 否 | 付费: 否

答案:

Spring boot starter is a maven template that contains a collection of all the relevant transitive dependencies that are needed to start a particular functionality. Like we need to import spring-boot-starter-web dependency for creating a web application.

Spring Boot starter 是一个 Maven 模板,包含启动特定功能所需的所有相关传递依赖的集合。例如,我们需要导入 spring-boot-starter-web 依赖来创建 Web 应用程序。


org.springframework.boot
org.springframework.boot
spring-boot-starter-web
spring-boot-starter-web

301. What is Spring Initializer?

什么是Spring Initializer?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7abe | 官方: 否 | 付费: 否

答案:

Spring Initializer is a web application that helps you to create an initial spring boot project structure and provides a maven or gradle file to build your code. It solves the problem of setting up a framework when you are starting a project from scratch.

Spring Initializer是一个Web应用程序,帮助你创建初始的Spring Boot项目结构,并提供用于构建代码的Maven或Gradle文件。它解决了从零开始项目时设置框架的问题。

302. What is Spring Boot CLI and what are its benefits?

什么是Spring Boot CLI,它有哪些好处?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ac1 | 官方: 否 | 付费: 否

答案:

Spring Boot CLI is a command-line interface that allows you to create a spring-based java application using Groovy.

Spring Boot CLI是一个命令行界面,允许你使用Groovy创建基于Spring的Java应用程序。

Example: You don’t need to create getter and setter method or access modifier, return statement. If you use the JDBC template, it automatically loads for you.

示例:你不需要创建getter和setter方法或访问修饰符、返回语句。如果你使用JDBC模板,它会自动为你加载。

303. What are the most common Spring Boot CLI commands?

最常见的Spring Boot CLI命令有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ac4 | 官方: 否 | 付费: 否

答案:

-run, -test, -grap, -jar, -war, -install, -uninstall, --init, -shell, -help.

-run、-test、-grap、-jar、-war、-install、-uninstall、--init、-shell、-help。

To check the description, run spring --help from the terminal.

要查看描述,请从终端运行spring --help。

Spring Boot CLI Commands

Spring Boot CLI命令

Advanced Spring Boot Questions

304. How to get the list of all the beans in your Spring boot application?

如何获取Spring Boot应用程序中所有Bean的列表?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7ac7 | 官方: 否 | 付费: 否

答案:

Spring Boot actuator “/Beans” is used to get the list of all the spring beans in your application.

Spring Boot Actuator的“/Beans”端点用于获取应用程序中所有Spring Bean的列表。

305. What is an IOC container?

什么是IoC容器?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7acc | 官方: 否 | 付费: 否

答案:

IoC Container is a framework for implementing automatic dependency injection. It manages object creation and its life-time and also injects dependencies into the class.

IoC容器是一个用于实现自动依赖注入的框架。它管理对象的创建及其生命周期,并将依赖注入到类中。

Important Resources - Java Spring Boot Free Course with Certificate

重要资源 - Java Spring Boot免费课程(含证书)
  • Spring vs Spring Boot
  • Difference Between Spring MVC and Spring Boot
  • Spring Interview Questions
  • Spring Security Interview Questions

306. Where do we define properties in the Spring Boot application?

我们在 Spring Boot 应用程序中在哪里定义属性?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ad5 | 官方: 否 | 付费: 否

答案:

You can define both application and Spring boot-related properties into a file called application.properties. You can create this file manually or use Spring Initializer to create this file. You don’t need to do any special configuration to instruct Spring Boot to load this file, If it exists in classpath then spring boot automatically loads it and configure itself and the application code accordingly.

你可以将应用程序和 Spring Boot 相关的属性都定义在一个名为 application.properties 的文件中。你可以手动创建此文件,也可以使用 Spring Initializer 来创建。你无需进行任何特殊配置来指示 Spring Boot 加载此文件,如果它存在于类路径中,Spring Boot 会自动加载它,并相应地配置自身和应用程序代码。

307. How to enable debugging log in the spring boot application?

如何在 Spring Boot 应用程序中启用调试日志?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ad8 | 官方: 否 | 付费: 否

答案:

Debugging logs can be enabled in three ways - - We can start the application with --debug switch.

可以通过三种方式启用调试日志——我们可以使用 --debug 开关启动应用程序。
  • We can set the logging.level.root=debug property in application.property file.
  • We can set the logging level of the root logger to debug in the supplied logging configuration file.

308. How to check the environment properties in your Spring boot application?

如何检查 Spring Boot 应用程序中的环境属性?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7adb | 官方: 否 | 付费: 否

答案:

Spring Boot actuator “/env” returns the list of all the environment properties of running the spring boot application.

Spring Boot actuator 的 “/env” 端点会返回正在运行的 Spring Boot 应用程序的所有环境属性列表。

309. Can we override or replace the Embedded tomcat server in Spring Boot?

我们能否在 Spring Boot 中覆盖或替换嵌入式 Tomcat 服务器?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ade | 官方: 否 | 付费: 否

答案:

Yes, we can replace the Embedded Tomcat server with any server by using the Starter dependency in the pom.xml file. Like you can use spring-boot-starter-jetty as a dependency for using a jetty server in your project.

可以,我们可以通过使用 pom.xml 文件中的 Starter 依赖来将嵌入式 Tomcat 服务器替换为任何服务器。例如,你可以使用 spring-boot-starter-jetty 作为依赖,以便在你的项目中使用 Jetty 服务器。

310. What Are the Basic Annotations that Spring Boot Offers?

Spring Boot 提供哪些基本注解?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ae1 | 官方: 否 | 付费: 否

答案:

The primary annotations that Spring Boot offers reside in its org.springframework.boot.autoconfigure and its sub-packages. Here are a couple of basic ones:

Spring Boot 提供的主要注解驻留在其 org.springframework.boot.autoconfigure 及其子包中。以下是几个基本的注解:

@EnableAutoConfiguration – to make Spring Boot look for auto-configuration beans on its classpath and automatically apply them.

@EnableAutoConfiguration – 使 Spring Boot 在其类路径上查找自动配置 bean 并自动应用它们。

@SpringBootApplication – used to denote the main class of a Boot Application. This annotation combines @Configuration, @EnableAutoConfiguration, and @ComponentScan annotations with their default attributes.

@SpringBootApplication – 用于表示 Boot 应用程序的主类。此注解结合了 @Configuration、@EnableAutoConfiguration 和 @ComponentScan 注解及其默认属性。

311. What is Spring Boot dependency management?

什么是 Spring Boot 依赖管理?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ae4 | 官方: 否 | 付费: 否

答案:

Spring Boot dependency management is used to manage dependencies and configuration automatically without you specifying the version for any of that dependencies.

Spring Boot 依赖管理用于自动管理依赖和配置,无需你为任何这些依赖指定版本。

312. Can we create a non-web application in Spring Boot?

我们可以在 Spring Boot 中创建非 Web 应用程序吗?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7ae7 | 官方: 否 | 付费: 否

答案:

Yes, we can create a non-web application by removing the web dependencies from the classpath along with changing the way Spring Boot creates the application context.

可以,我们可以通过从类路径中移除 Web 依赖,并更改 Spring Boot 创建应用程序上下文的方式来创建非 Web 应用程序。

313. Is it possible to change the port of the embedded Tomcat server in Spring Boot?

是否可以在Spring Boot中更改内嵌Tomcat服务器的端口?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7aea | 官方: 否 | 付费: 否

答案:

Yes, it is possible. By using the server.port in the application.properties .

是的,可以。通过在application.properties中使用server.port来实现。

314. What is the default port of tomcat in spring boot?

Spring Boot中tomcat的默认端口是什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7aed | 官方: 否 | 付费: 否

答案:

The default port of the tomcat server-id 8080. It can be changed by adding sever.port properties in the application.property file.

tomcat服务器的默认端口是8080。可以通过在application.property文件中添加server.port属性来更改它。

315. What are the actuator-provided endpoints used for monitoring the Spring boot application?

用于监控Spring Boot应用程序的actuator提供的端点有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7af0 | 官方: 否 | 付费: 否

答案:

Actuators provide below pre-defined endpoints to monitor our application - - Health

Actuators提供以下预定义端点来监控我们的应用程序——健康检查(Health)
  • Info
  • Beans
  • Mappings
  • Configprops
  • Httptrace
  • Heapdump
  • Threaddump
  • Shutdown

316. Can we disable the default web server in the Spring boot application?

我们能在Spring Boot应用程序中禁用默认的Web服务器吗?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7af3 | 官方: 否 | 付费: 否

答案:

Yes, we can use application.properties to configure the web application type i.e spring.main.web-application-type=none.

是的,我们可以使用application.properties来配置Web应用程序类型,即spring.main.web-application-type=none。

317. How to disable a specific auto-configuration class?

如何禁用特定的自动配置类?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7af6 | 官方: 否 | 付费: 否

答案:

You can use exclude attribute of @EnableAutoConfiguration if you want auto-configuration not to apply to any specific class.

如果你不想让自动配置应用于任何特定类,可以使用@EnableAutoConfiguration的exclude属性。

//use of exclude

//使用exclude
@EnableAutoConfiguration(exclude={className})
@EnableAutoConfiguration(exclude={className})

318. Explain @RestController annotation in Spring boot?

解释Spring Boot中的@RestController注解?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7af9 | 官方: 否 | 付费: 否

答案:

It is a combination of @Controller and @ResponseBody, used for creating a restful controller. It converts the response to JSON or XML. It ensures that data returned by each method will be written straight into the response body instead of returning a template.

它是@Controller和@ResponseBody的组合,用于创建RESTful控制器。它将响应转换为JSON或XML。它确保每个方法返回的数据直接写入响应体,而不是返回模板。

319. What is the difference between @RestController and @Controller in Spring Boot?

在Spring Boot中,@RestController和@Controller有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7afc | 官方: 否 | 付费: 否

答案:

@Controller Map of the model object to view or template and make it human readable but @RestController simply returns the object and object data is directly written in HTTP response as JSON or XML.

@Controller将模型对象映射到视图或模板并使其可读,但@RestController仅返回对象,对象数据直接以JSON或XML形式写入HTTP响应中。

320. Describe the flow of HTTPS requests through the Spring Boot application?

描述HTTPS请求在Spring Boot应用中的流转过程?
  • 知识点: 后端 / 编程语言基础 / 行为与软技能 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b03 | 官方: 否 | 付费: 否

答案:

On a high-level spring boot application follow the MVC pattern which is depicted in the below flow diagram.

从高层来看,Spring Boot应用遵循MVC模式,如下流程图所示。

Spring Boot Flow Architecture

Spring Boot流程架构

321. What is the difference between RequestMapping and GetMapping?

RequestMapping和GetMapping有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b06 | 官方: 否 | 付费: 否

答案:

RequestMapping can be used with GET, POST, PUT, and many other request methods using the method attribute on the annotation. Whereas getMapping is only an extension of RequestMapping which helps you to improve on clarity on request.

RequestMapping可以使用GET、POST、PUT以及许多其他请求方法,通过注解上的method属性实现。而GetMapping只是RequestMapping的一个扩展,帮助你在请求上提高清晰度。

322. What is the use of Profiles in spring boot?

在Spring Boot中Profiles有什么用?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b09 | 官方: 否 | 付费: 否

答案:

While developing the application we deal with multiple environments such as dev, QA, Prod, and each environment requires a different configuration. For eg., we might be using an embedded H2 database for dev but for prod, we might have proprietary Oracle or DB2. Even if DBMS is the same across the environment, the URLs will be different.

在开发应用程序时,我们会处理多个环境,如开发、质量保证和生产,每个环境需要不同的配置。例如,我们可能为开发使用嵌入式H2数据库,但对于生产,我们可能有专有的Oracle或DB2。即使DBMS在环境中相同,URL也会不同。

To make this easy and clean, Spring has the provision of Profiles to keep the separate configuration of environments.

为了使其简单且干净,Spring提供了Profiles的功能来保持环境的单独配置。

323. What is Spring Actuator? What are its advantages?

什么是Spring Actuator?它有什么优点?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b0c | 官方: 否 | 付费: 否

答案:

An actuator is an additional feature of Spring that helps you to monitor and manage your application when you push it to production. These actuators include auditing, health, CPU usage, HTTP hits, and metric gathering, and many more that are automatically applied to your application.

Actuator是Spring的一个附加功能,帮助你在将应用程序推送到生产环境时监控和管理它。这些actuator包括审计、健康、CPU使用率、HTTP点击次数和指标收集等,以及更多自动应用于你应用程序的功能。

324. How to enable Actuator in Spring boot application?

如何在Spring Boot应用中启用Actuator?
  • 知识点: 后端 / 编程语言基础 (主题: spring-boot, java, backend;标签: interviewbit, spring-boot, topic-specific, java, backend)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b0f | 官方: 否 | 付费: 否

答案:

To enable the spring actuator feature, we need to add the dependency of “spring-boot-starter-actuator” in pom.xml.

要启用Spring actuator功能,我们需要在pom.xml中添加“spring-boot-starter-actuator”依赖。


org.springframework.boot
org.springframework.boot
spring-boot-starter-actuator
spring-boot-starter-actuator

325. What is Spring security authentication and authorization?

什么是Spring Security认证和授权?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b3a | 官方: 否 | 付费: 否

答案:

  • Authentication: This refers to the process of verifying the identity of the user, using the credentials provided when accessing certain restricted resources. Two steps are involved in authenticating a user, namely identification and verification. An example is logging into a website with a username and a password. This is like answering the question Who are you?
  • Authorization: It is the ability to determine a user's authority to perform an action or to view data, assuming they have successfully logged in. This ensures that users can only access the parts of a resource that they are authorized to access. It could be thought of as an answer to the question Can a user do/read this?

326. What do you mean by digest authentication?

你所说的摘要认证是什么意思?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b3d | 官方: 否 | 付费: 否

答案:

RESTful web services can be authenticated in many ways, but advanced authentication methods include digest authentication. It applies a hash function to username, password, HTTP method, and URI in order to send credentials in encrypted form. It generates more complex cryptographic results by using the hashing technique which is not easy to decode.

RESTful Web服务可以通过多种方式进行认证,但高级认证方法包括摘要认证。它对用户名、密码、HTTP方法和URI应用哈希函数,以便以加密形式发送凭据。它通过使用不易解码的哈希技术生成更复杂的加密结果。

Syntax:

语法:

Hash1=MD5(username:realm:password)

Hash1=MD5(username:realm:password)
Hash2=MD5(method:digestURI)
Hash2=MD5(method:digestURI)
response=MD5(Hash1:nonce:nonceCount:cnonce:qop:Hash2)
response=MD5(Hash1:nonce:nonceCount:cnonce:qop:Hash2)
//Example, this got generated by running this example
//示例,这是通过运行此示例生成的
Authorization: Digest username="TestAdmin", realm="admin-digest-realm", nonce="MTYwMDEwMTUyMDM4OToxM2M1Y2I4MGFjMjk4OGI1ODQzZjc3NDUzOGFlMjZjYw==", uri="/admin/hello?name=User", response="2f080edbec53be2bdf3853d477e4a543", qop=auth, nc=00000002, cnonce="11ecd9bf947dbcf4"
Authorization: Digest username="TestAdmin", realm="admin-digest-realm", nonce="MTYwMDEwMTUyMDM4OToxM2M1Y2I4MGFjMjk4OGI1ODQzZjc3NDUzOGFlMjZjYw==", uri="/admin/hello?name=User", response="2f080edbec53be2bdf3853d477e4a543", qop=auth, nc=00000002, cnonce="11ecd9bf947dbcf4"

327. What are some essential features of Spring Security?

Spring Security的一些基本特性是什么?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b40 | 官方: 否 | 付费: 否

答案:

Some essential features of Spring Security include: - Supports authentication and authorization in a flexible and comprehensive manner.

Spring Security的一些基本特性包括:- 以灵活且全面的方式支持认证和授权。
  • Detection and prevention of attacks including session fixation, clickjacking, cross-site request forgery, etc.
  • Integrate with Servlet API.
  • Offers optional integration with Spring Web MVC (Model-View-Controller).
  • Java Authentication and Authorization Service (JAAS) is used for authentication purposes.
  • Allows Single Sign-On so that users can access multiple applications with just one account (username and password).

328. What do you mean by basic authentication?

你所说的基本认证是什么意思?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b43 | 官方: 否 | 付费: 否

答案:

RESTful web services can be authenticated in many ways, but the most basic one is basic authentication. For basic authentication, we send a username and password using the HTTP [Authorization] header to enable us to access the resource. Usernames and passwords are encoded using base64 encoding (not encryption) in Basic Authentication. The encoding is not secure since it can be easily decoded.

RESTful Web服务可以通过多种方式进行认证,但最基本的是基本认证。对于基本认证,我们使用HTTP [Authorization]头发送用户名和密码,以便访问资源。在基本认证中,用户名和密码使用base64编码(而非加密)进行编码。这种编码不安全,因为它很容易被解码。

Syntax:

语法:

Value = username:password

Value = username:password
Encoded Value = base64(Value)
Encoded Value = base64(Value)
Authorization Value = Basic
Authorization Value = Basic
//Example: Authorization: Basic VGVzdFVzZXI6dGVzdDEyMw==
//示例:Authorization: Basic VGVzdFVzZXI6dGVzdDEyMw==
//Decode it'll give back the original username:password UserName:user123
//解码后它将返回原始的username:password UserName:user123

329. Is security a cross-cutting concern?

安全性是否是一个横切关注点?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b46 | 官方: 否 | 付费: 否

答案:

Spring Security is indeed a cross-cutting concern. Spring security is also using Spring AOP (Aspect Oriented Programming) internally. A cross-cutting concern is one that applies throughout the whole application and affects it all. Below are some cross-cutting concerns related to the enterprise application. - Logging and tracing

Spring Security确实是一个横切关注点。Spring Security内部也使用了Spring AOP(面向切面编程)。横切关注点是适用于整个应用程序并影响其所有部分的一种关注点。以下是一些与企业应用程序相关的横切关注点。- 日志记录和跟踪
  • Transaction management
  • Security
  • Caching
  • Error handling
  • Performance monitoring
  • Custom Business Rules
  • Data Science
  • All Events
  • My Events

330. Explain AbstractSecurityInterceptor in spring security?

解释Spring Security中的AbstractSecurityInterceptor?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b49 | 官方: 否 | 付费: 否

答案:

In Spring Security, the AbstractSecurityInterceptor handles the initial authorization of incoming requests. AbstractSecurityInterceptor has two concrete implementations: - FilterSecurityInterceptor: It will authorize all authenticated user requests.

在Spring Security中,AbstractSecurityInterceptor处理传入请求的初始授权。AbstractSecurityInterceptor有两个具体实现:- FilterSecurityInterceptor:它将授权所有经过认证的用户请求。
  • MethodSecurityInterceptor: This is crucial for implementing method-level security. It allows us to secure our program at the method level.

331. What is PasswordEncoder?

什么是PasswordEncoder?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b4c | 官方: 否 | 付费: 否

答案:

Password encoding is provided by Spring Security using the PasswordEncoder interface. This interface defines two methods: - encode(): It converts a plain password into an encoded form.

Spring Security使用PasswordEncoder接口提供密码编码。该接口定义了两个方法:- encode():它将明文密码转换为编码形式。
  • matches(): It compares an encoded password from the database with a plain password (input by the user) that's been encoded using the same salting and hashing algorithm as the encoded password.

332. Explain salting and its usage.

解释盐值及其用途。
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b4f | 官方: 否 | 付费: 否

答案:

Spring Security automatically applies salting since version 3.1. Salting is the process of combining random data with a password before password hashing. Salt improves hashing by increasing its uniqueness and complexity without increasing the requirements for users, thereby reducing password attacks. Hashed passwords are then stored in a database, along with salt. Your application will be protected from Dictionary-Attack by using salting. With Salt, you can add an extra string to the password to make it more difficult for hackers to crack it.

Spring Security自3.1版本起自动应用盐值。盐值是在密码哈希之前将随机数据与密码结合的过程。盐值通过增加哈希的唯一性和复杂性来提高哈希安全性,而不增加用户的要求,从而减少密码攻击。哈希后的密码与盐值一起存储在数据库中。通过使用盐值,您的应用程序将免受字典攻击。使用盐值,您可以向密码添加额外的字符串,使黑客更难破解它。

333. What do you mean by HASHING in spring security?

在Spring Security中,HASHING是什么意思?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b52 | 官方: 否 | 付费: 否

答案:

Databases often suffer from security problems when storing passwords. Plain text passwords cannot be stored in your database because then anyone who has access to the database would know the passwords of every user. The solution to this problem is to store encrypted passwords in a database. This is called password hashing.

当存储密码时,数据库经常面临安全问题。明文密码不能存储在数据库中,因为任何有权访问数据库的人都会知道每个用户的密码。解决此问题的方法是在数据库中存储加密密码。这称为密码哈希。

As part of a general security concept, Hashing involves encoding a string according to the hashing algorithm used. MD4, MD5, SHA (Security Hashing Algorithm) like SHA256 SHA128, etc., are some of the hashing algorithms that can be applied. The hashing method should take the password as input and return a hashed string, which should be stored in a database rather than plain text.

作为一般安全概念的一部分,哈希涉及根据所使用的哈希算法对字符串进行编码。MD4、MD5、SHA(安全哈希算法)如SHA256、SHA128等是一些可应用的哈希算法。哈希方法应将密码作为输入,并返回一个哈希字符串,该字符串应存储在数据库中,而不是明文。

334. What is method security and why do we need it?

什么是方法安全性,为什么我们需要它?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b55 | 官方: 否 | 付费: 否

答案:

Simply put, Spring method security lets us add or support authorization at the method level. Spring security checks the authorization of the logged-in user in addition to authentication. Upon login, the ROLE of the user is used to determine which user is authorized to access the resource. When creating a new user in WebSecurityConfig, we can specify his ROLE as well. A security measure applied to a method prevents unauthorized users and only allows authentic users. The purpose of method level security is not to facilitate users who have access but to prevent unauthorized users from performing activities beyond their privileges and roles. Method level security is implemented using AOP ( Aspect-Oriented Programming ).

简单来说,Spring方法安全性让我们在方法级别添加或支持授权。Spring Security在认证之外还检查已登录用户的授权。登录时,用户的ROLE用于确定哪个用户有权访问资源。在WebSecurityConfig中创建新用户时,我们也可以指定其ROLE。应用于方法的安全措施防止未经授权的用户,只允许真实用户。方法级安全性的目的不是为了方便有访问权限的用户,而是防止未授权用户执行超出其权限和角色的操作。方法级安全性是使用AOP(面向切面编程)实现的。

335. What do you mean by OAuth2 Authorization code grant type?

你所说的OAuth2授权码授权类型是什么意思?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b58 | 官方: 否 | 付费: 否

答案:

The term "grant type" in OAuth 2.0 refers to the way an application gets an access token. The authorization code flow is one of several types of grants defined by OAuth 2.0. This grant is used by both web applications and native applications to obtain an access token after a user authorizes the application. As opposed to most other grant types, it requires the application to first launch a browser to begin the process/flow. The process involves the following steps: - The application opens a browser to direct the user to an OAuth server.

在OAuth 2.0中,术语“grant type”(授权类型)指的是应用程序获取访问令牌的方式。授权码流程是OAuth 2.0定义的几种授权类型之一。这种授权类型被Web应用程序和原生应用程序用来在用户授权应用程序后获取访问令牌。与大多数其他授权类型不同,它要求应用程序首先启动浏览器以开始该流程。该流程涉及以下步骤:- 应用程序打开浏览器,将用户引导到OAuth服务器。
  • Upon seeing the authorization prompt, the user approves the application's request.
  • Upon approval, the user is redirected back to the application with an authorization code in the query string.
  • Application exchange authorization codes for access tokens.

336. Explain spring security OAuth2.

解释Spring Security OAuth2。
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b5b | 官方: 否 | 付费: 否

答案:

A simple authorization framework, OAuth 2.0, permits client applications to access protected resources via an authorization server. Using it, a client application (third party) can gain limited access to an HTTP service on behalf of the resource owner or on its own behalf.

一个简单的授权框架,OAuth 2.0,允许客户端应用程序通过授权服务器访问受保护的资源。使用它,客户端应用程序(第三方)可以代表资源所有者或代表其自身获得对HTTP服务的有限访问权限。

In OAuth2, four roles are available as shown below: - Resource Owner/User: The owner of a resource, i.e., the individual who holds the rights to that resource.

在OAuth2中,有四种角色可用,如下所示:- 资源所有者/用户:资源的所有者,即持有该资源权利的个人。
  • Client: The application requests an access token (represents a user's permission for the client to access their data/resources), then accesses the protected resource server after receiving the access token.
  • Authorization Server: After successfully authenticating the resource owner and obtaining authorization, the server issues access tokens to the client.
  • Resource Server: It provides access to requested resources. Initially, it validates the access tokens, then it provides authorization.

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

337. Explain SecurityContext and SecurityContext Holder in Spring security.

解释Spring Security中的SecurityContext和SecurityContextHolder。
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b5e | 官方: 否 | 付费: 否

答案:

There are two fundamental classes of Spring Security: SecurityContext and SecurityContextHolder. - SecurityContext: In this, information/data about the currently authenticated user (also known as the principal) is stored. So, in order to obtain a username or any other information about the user, you must first obtain the SecurityContext.

Spring Security有两个基本类:SecurityContext和SecurityContextHolder。- SecurityContext:在此存储当前已认证用户(也称为主体)的信息/数据。因此,为了获取用户名或关于用户的任何其他信息,您必须首先获取SecurityContext。
  • SecurityContextHolder: Retrieving the currently authenticated principal is easiest via a static call to the SecurityContextHolder. As a helper class, it provides access to the security context. By default, it uses a ThreadLocal object to store SecurityContext, so SecurityContext is always accessible to methods in the same thread of execution, even if SecurityContext isn't passed around.

338. What do you mean by session management in Spring Security?

在Spring Security中,会话管理是什么意思?
  • 知识点: 后端 / 安全 / 编程语言基础 (主题: spring, security, java;标签: interviewbit, spring-security, topic-specific, spring, security, java)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5a58d557c902bc7b61 | 官方: 否 | 付费: 否

答案:

As far as security is concerned, session management relates to securing and managing multiple users' sessions against their request. It facilitates secure interactions between a user and a service/application and pertains to a sequence of requests and responses associated with a particular user. Session Management is one of the most critical aspects of Spring security as if sessions are not managed properly, the security of data will suffer. To control HTTP sessions, Spring security uses the following options: - SessionManagementFilter.

就安全而言,会话管理涉及保护和管理多个用户的会话以应对其请求。它促进用户与服务/应用程序之间的安全交互,并与特定用户关联的一系列请求和响应有关。会话管理是Spring Security中最关键的方面之一,因为如果会话管理不当,数据的安全性将受到影响。为了控制HTTP会话,Spring Security使用以下选项:- SessionManagementFilter。
  • SessionAuthneticationStrategy
    With these two, spring-security can manage the following security session options: - Session timeouts (amount of time a user can remain inactive on a website before the site ends the session.)

    使用这两个,spring-security可以管理以下安全会话选项:- 会话超时(用户在网站结束会话前可以保持不活动的时间量。)
  • Concurrent sessions (the number of sessions that an authenticated user can have open at once).
  • Session-fixation (an attack that permits an attacker to hijack a valid user session).

339. Can you explain the concept of microservices and how it differs from a monolithic architecture?

你能解释一下微服务的概念以及它与单体架构有何不同吗?
  • 知识点: 后端 / 系统设计/架构 (标签: interviewbit, tcs-digital, company-specific)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: general
  • 公司: Tata Consultancy Services
  • id: 69b37c6d58d557c902bc8637 | 官方: 否 | 付费: 否

答案:

Microservices is an architectural style that involves building a software system as a collection of small, independent services that communicate with each other over a network. Each service is responsible for a specific function or capability, and it is designed to be scalable, maintainable, and resilient.

微服务是一种架构风格,它将软件系统构建为一组小型、独立的服务集合,这些服务通过网络相互通信。每个服务负责特定的功能或能力,并且被设计为可扩展、可维护且具有弹性。

In the above image, we can see that there are multiple systems connected with the interface, this individual system can perform some individual and independent tasks. The Interface is responsible to handle that type of task/request and route it to the specific system for the response.

在上图中,我们可以看到有多个系统与接口相连,这些独立的系统可以执行一些单独且独立的任务。接口负责处理那类任务/请求,并将其路由到特定的系统以获取响应。

A microservices architecture has several advantages, such as: - Decoupling: The separation of services allows for greater decoupling of the system, which makes it easier to modify, test, and deploy individual services without affecting the rest of the system.

微服务架构有几个优点,例如:- 解耦:服务的分离使得系统能够更大程度地解耦,从而更容易修改、测试和部署单个服务,而不影响系统的其余部分。
  • Scalability: The independent nature of the services allows for greater scalability, as each service can be scaled up or down independently.
  • Resilience: The independent nature of the services allows for greater resilience, as the failure of one service does not affect the rest of the system.
  • Flexibility: The use of small, independent services allows for greater flexibility, as the system can be modified and enhanced by adding or modifying individual services.
    A monolithic architecture, on the other hand, involves building the software system as a single, large, cohesive unit. A monolithic architecture has several disadvantages, such as: - Coupling: The lack of separation between the components of the system leads to greater coupling, which makes it harder to modify, test, and deploy individual components without affecting the rest of the system.

    另一方面,单体架构将软件系统构建为一个单一的、大型的、内聚的单元。单体架构有几个缺点,例如:- 耦合:系统组件之间缺乏分离会导致更大的耦合,这使得在不影响系统其余部分的情况下修改、测试和部署单个组件变得更加困难。
  • Scalability: The single, large nature of the system limits scalability, as the entire system needs to be scaled up or down as a whole.
  • Resilience: The single, large nature of the system limits resilience, as the failure of one component can affect the entire system.
  • Flexibility: The single, large nature of the system limits flexibility, as it is harder to add or modify individual components without affecting the rest of the system.
    In the above image, we can see that the entire application is clubbed into a single differed by the User Interface, Business logic, and Data Access Layer.

    在上图中,我们可以看到整个应用程序被合并为一个整体,由用户界面、业务逻辑和数据访问层组成。

340. What is a continuous integration and delivery pipeline and how do you implement it?

什么是持续集成和交付流水线,你如何实现它?
  • 知识点: 后端 (标签: interviewbit, tcs-digital, company-specific)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: general
  • 公司: Tata Consultancy Services
  • id: 69b37c6d58d557c902bc864b | 官方: 否 | 付费: 否

答案:

Continuous integration and continuous delivery (CI/CD) is a software development practice that involves integrating code changes frequently, building and testing the code automatically, and deploying the code to production as soon as it is ready. The goal of CI/CD is to reduce the time and effort required to develop and deploy software, and to improve the quality and reliability of the software.

持续集成和持续交付(CI/CD)是一种软件开发实践,涉及频繁集成代码变更、自动构建和测试代码,并在代码准备就绪后立即部署到生产环境。CI/CD 的目标是减少开发和部署软件所需的时间和精力,并提高软件的质量和可靠性。

In the above image, we can see how continuous delivery and continuous integration communicate for better delivery of software. It typically consists of the following steps:

在上图中,我们可以看到持续交付和持续集成如何通信以实现更好的软件交付。它通常包括以下步骤:
  1. Plan: This stage involves defining the requirements and goals for the software project. 2. Code: The code stage involves writing the software code to meet the requirements and goals defined in the planning stage. 3. Build: The build step involves compiling the code and creating an executable version of the software, which can be done automatically using a build tool like Make or Gradle. 4. Continuous Testing: This stage involves running a set of automated tests to ensure that the code is correct and meets the specified requirements. This can include unit tests, integration tests, and functional tests. 5. Release: The release stage involves finalizing the code for a specific release, which can include bug fixes, new features, and other changes. 6. Deploy: The deploy step involves deploying the code to a production environment, such as a staging or production server, which can be done automatically using a deployment tool like Ansible or Jenkins. 7. Operate: The operating stage involves managing the software and infrastructure in a production environment, which can include monitoring performance, managing resources, and addressing any issues that arise. 8. Monitor: The monitor stage involves monitoring the software and infrastructure to identify issues or opportunities for improvement, which can inform future updates or releases.

    1. 计划:此阶段涉及定义软件项目的需求和目标。 2. 编码:编码阶段涉及编写软件代码以满足计划阶段定义的需求和目标。 3. 构建:构建步骤涉及编译代码并创建软件的可执行版本,可以使用 Make 或 Gradle 等构建工具自动完成。 4. 持续测试:此阶段涉及运行一组自动化测试,以确保代码正确并满足指定的需求。这可以包括单元测试、集成测试和功能测试。 5. 发布:发布阶段涉及为特定版本最终确定代码,其中可以包括错误修复、新功能和其他更改。 6. 部署:部署步骤涉及将代码部署到生产环境,例如暂存或生产服务器,可以使用 Ansible 或 Jenkins 等部署工具自动完成。 7. 运营:运营阶段涉及在生产环境中管理软件和基础设施,其中可以包括监控性能、管理资源和解决出现的任何问题。 8. 监控:监控阶段涉及监控软件和基础设施,以识别问题或改进机会,这可以为未来的更新或发布提供信息。

To implement a CI/CD pipeline, you need to choose the tools and processes that are appropriate for your project and set up the pipeline accordingly. This typically involves configuring the code repository, setting up the build and test tools, and configuring the deployment process. Some of the tools available in the market are:

要实现 CI/CD 流水线,您需要选择适合您项目的工具和流程,并相应地设置流水线。这通常涉及配置代码仓库、设置构建和测试工具,以及配置部署流程。市场上可用的一些工具包括:
  1. Jenkins: Jenkins is a popular open-source automation server that is widely used for continuous integration and continuous delivery. It allows for the automation of building, testing, and deploying software applications, and provides a wide range of plugins and integrations for different development environments and tools. 2. GitLab: GitLab is a web-based Git repository manager that provides integrated support for continuous integration and delivery. It offers features such as code review, issue tracking, and wiki documentation, as well as built-in continuous integration and delivery pipelines that can be configured to automatically test and deploy code changes. 3. Travis CI: Travis CI is a cloud-based continuous integration service that is widely used by open-source software projects. It provides a range of features for building and testing software applications, including support for multiple programming languages and frameworks, and integration with popular code hosting platforms such as GitHub and Bitbucket.

    1. Jenkins:Jenkins 是一个流行的开源自动化服务器,广泛用于持续集成和持续交付。它允许自动化构建、测试和部署软件应用程序,并为不同的开发环境和工具提供广泛的插件和集成。 2. GitLab:GitLab 是一个基于 Web 的 Git 仓库管理器,提供对持续集成和交付的集成支持。它提供代码审查、问题跟踪和 wiki 文档等功能,以及内置的持续集成和交付流水线,可以配置为自动测试和部署代码变更。 3. Travis CI:Travis CI 是一个基于云的持续集成服务,被开源软件项目广泛使用。它提供一系列用于构建和测试软件应用程序的功能,包括对多种编程语言和框架的支持,以及与 GitHub 和 Bitbucket 等流行代码托管平台的集成。

341. Given a binary tree's root, determine whether it is a BST. Then, determine whether it is a valid BST. A BST is a tree in which both subtrees are binary search trees and in which the subtrees of each node are also BSTs.

给定二叉树的根节点,判断它是否为 BST。然后,判断它是否为有效的 BST。BST 是一种树,其中两个子树都是二叉搜索树,并且每个节点的子树也都是 BST。
  • 知识点: 后端 / 算法与数据结构 (标签: interviewbit, virtusa, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Virtusa
  • id: 69b37c8a58d557c902bc9414 | 官方: 否 | 付费: 否

答案:

We can easily solve this problem with the help of recursion. Just we need to see that every subtree must be a binary search tree. So here is the approach for the solution using the recursion.

我们可以借助递归轻松解决这个问题。只需注意每个子树都必须是二叉搜索树。因此,这里是使用递归的解决方案方法。

class Solution {

class Solution {
//private method that validates the tree by the values of root and sub roots
//私有方法,通过根节点和子根节点的值来验证树
private boolean solution(TreeNode root, long left, long right){
private boolean solution(TreeNode root, long left, long right){
//Base case to determine if we reach the leaf of the
//基本情况,用于判断是否到达树的叶子节点
//tree and found no error. Then the part is the valid BST
//并且未发现错误。那么该部分就是有效的 BST
if(root == null)
if(root == null)
return true;
返回 true;

//Comparing the value of the subtrees that all values to

//比较子树的值,即所有值到
//its sub tree must fulfill the condition of validity.
//其子树都必须满足有效性条件。
if(!(root.val < right && root.val > left))
if(!(root.val < right && root.val > left))
return false;
返回 false;

//Recursively validating it's right subtree and left subtree.

//递归地验证其右子树和左子树。
return ((solution(root.left, left, root.val)) &&
return ((solution(root.left, left, root.val)) &&
(solution(root.right, root.val, right)));
(solution(root.right, root.val, right)));

}
//Method that validates and returns true if it's valid.

//验证并返回 true(如果有效)的方法。
public boolean isValidBST(TreeNode root) {
public boolean isValidBST(TreeNode root) {
//Calling private helper method to validate.
//调用私有辅助方法进行验证。
return solution(root, Long.MIN_VALUE, Long.MAX_VALUE);
return solution(root, Long.MIN_VALUE, Long.MAX_VALUE);
}
}

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

342. What is REST API?

什么是 REST API?
  • 知识点: 后端 (标签: interviewbit, virtusa, company-specific)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: general
  • 公司: Virtusa
  • id: 69b37c8a58d557c902bc9445 | 官方: 否 | 付费: 否

答案:

REST API (Representational State Transfer) is an architectural style used to describe the transfer of information between web services. REST describes three types of interactions: request and response, PUT and GET, and resource and representation. These interactions can be performed over standard HTTP requests, but REST also provides a contract that describes the types of data that can be transferred, how it can be formatted, and what methods can be used to manipulate it.

REST API(表述性状态转移)是一种架构风格,用于描述 Web 服务之间的信息传输。REST 描述了三种类型的交互:请求与响应、PUT 与 GET,以及资源与表示。这些交互可以通过标准 HTTP 请求执行,但 REST 还提供了一种契约,描述了可以传输的数据类型、数据的格式以及可用于操作数据的方法。

The concept behind REST API is to minimize the amount of data sent over the network. It does this by defining how data will be transferred (either PUT or POST) and what method will be used to do so (GET or DELETE).

REST API 背后的理念是尽量减少通过网络发送的数据量。它通过定义数据将如何传输(PUT 或 POST)以及将使用什么方法来进行传输(GET 或 DELETE)来实现这一点。

Another key aspect of REST API is that both client-sender and server-receiver must adhere to a set of rules that define how data will be transferred (e.g. which format/data format). The combination of these two elements allows for increased security in remote communication and ensures that no information can be passed between devices unless explicitly allowed by both parties.

REST API 的另一个关键方面是,客户端发送方和服务器接收方都必须遵守一套规则,这些规则定义了数据将如何传输(例如使用哪种格式/数据格式)。这两个要素的结合可以增强远程通信的安全性,并确保除非双方明确允许,否则任何信息都不能在设备之间传递。

REST API has become a popular architectural pattern among modern web applications because it reduces complexity while ensuring interoperability between web services. Although the concept of REST API might seem simple at first glance, there are several subtleties involved in building an application with this architectural style in mind. In particular, REST API requires both clients.

REST API 已成为现代 Web 应用中流行的架构模式,因为它在确保 Web 服务之间互操作性的同时降低了复杂性。尽管 REST API 的概念乍看之下似乎很简单,但在构建采用这种架构风格的应用时,仍涉及若干细微之处。特别是,REST API 要求客户端双方。

343. What is Web API and why we use it ?

什么是Web API,我们为什么使用它?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9158d557c902bc979e | 官方: 否 | 付费: 否

答案:

Web API (Application Programming Interface), as the name suggests, is an API that can be accessed over the Web using the HTTP protocol. It is basically considered the best platform for revealing or uncovering data and services to various different services. It is a tool that can be used to push data to a server and can be accessed by server code. It can be built or developed using various technologies like java, ASP.NET, etc.

Web API(应用程序编程接口),顾名思义,是一种可以通过HTTP协议在Web上访问的API。它基本上被认为是向各种不同服务揭示或公开数据和服务的最佳平台。它是一种可用于将数据推送到服务器的工具,并且可以被服务器代码访问。它可以使用各种技术构建或开发,如Java、ASP.NET等。

Web API Uses: - It contains additional layers that simply standardize communications and provide different options on how to format input and output.

Web API的用途:- 它包含额外层,这些层简化了标准化通信,并提供了关于如何格式化输入和输出的不同选项。
  • It can be used with ASP.NET MVC and different types of web applications such as ASP.NET WebForms.
  • If one wants to create resource-oriented services, then Web API services are considered the best.
  • It also helps to develop REST-ful services and SOAP-based services.

344. What is MVC? Write difference between MVC and Web API?

什么是MVC?写出MVC和Web API之间的区别?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9158d557c902bc97a1 | 官方: 否 | 付费: 否

答案:

MVC (Model, View, and Controller) is basically an application design model that comprises three interconnect parts I.e., model, view, and controller. It allows coders to factor out different components of the application and update them more easily. It is mostly used for developing model user interfaces. Its main purpose is to display patterns in structure for keeping display and data separate to enable both of them to change without affecting others.

MVC(模型、视图和控制器)基本上是一种应用程序设计模型,包含三个相互连接的部分,即模型、视图和控制器。它允许编码人员分解应用程序的不同组件并更容易地更新它们。它主要用于开发模型用户界面。其主要目的是在结构中显示模式,以保持显示和数据分离,使两者都能在不影响彼此的情况下变化。
| MVC | Web API |
It can be used to build Web applications that reply as both data and views.
它可用于构建既响应数据又响应视图的Web应用程序。
It is used to build HTTP services that reply only as data.
它用于构建仅响应数据的HTTP服务。
It returns data in JSON format by using JSONResult.
它通过使用JSONResult以JSON格式返回数据。
It returns data in different formats such as JSON, XML, etc.
它以不同格式返回数据,如JSON、XML等。
It supports content negotiation, self-hosting.
它支持内容协商、自托管。
It does not support content negotiation, self-hosting.
它不支持内容协商、自托管。
It is not able to build REST-full services.
它不能构建REST-ful服务。
It is very helpful in creating REST-full services.
它在创建REST-ful服务时非常有用。
It returns a view (HTML).
它返回视图(HTML)。
It returns REST responses.
它返回REST响应。

345. How to register an exception filter globally?

如何全局注册异常过滤器?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9158d557c902bc97a4 | 官方: 否 | 付费: 否

答案:

One can register exception filter globally using following code: GlobalConfiguration.Configuration.Filters.Add (new MyTestCustomerStore.NotImplExceptionFilterAttribute());

可以使用以下代码全局注册异常过滤器:GlobalConfiguration.Configuration.Filters.Add (new MyTestCustomerStore.NotImplExceptionFilterAttribute());

346. How to handle errors in Web API?

如何处理 Web API 中的错误?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9158d557c902bc97a7 | 官方: 否 | 付费: 否

答案:

Web API generally provides greater flexibility in terms of handling errors. Exception handling is a technique that is used to handle run-time errors in application code. One can use HttpResponseException, HttpError, Exception filters, register exception filters, Exception handlers to handle errors. Exception filter can be used to identify unhandled exceptions on actions or controllers, exception handlers can be used to identify any type of unhandled exception application-wide, and HttpResponseException can be used when there is the possibility of an exception.

Web API 在错误处理方面通常提供更大的灵活性。异常处理是一种用于处理应用程序代码中运行时错误的技术。可以使用 HttpResponseException、HttpError、异常过滤器、注册异常过滤器、异常处理器来处理错误。异常过滤器可用于识别操作或控制器上未处理的异常,异常处理器可用于识别应用程序范围内任何类型的未处理异常,而 HttpResponseException 可在存在异常可能性时使用。

347. Who can consume Web API?

谁可以使用 Web API?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc97ac | 官方: 否 | 付费: 否

答案:

A large range of clients such as browsers, mobile devices, iPhone, etc., include or consume web API. It is also good for using along native applications that require web services but not SOAP support. It can also be consumed by any client that supports HTTP verbs such as GET, DELETE, POST, PUT.

大量客户端(如浏览器、移动设备、iPhone 等)包含或使用 Web API。它也适用于需要 Web 服务但不支持 SOAP 的原生应用程序。任何支持 HTTP 动词(如 GET、DELETE、POST、PUT)的客户端也可以使用它。

348. What are Web API filters?

什么是 Web API 过滤器?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc97af | 官方: 否 | 付费: 否

答案:

Filters are basically used to add extra logic at different levels of Web API framework request processing. Different types of Web API filters are available as given below: - Authentication Filter: It handles authentication and authenticates HTTP requests. It also helps to authenticate user detail. It checks the identity of the user.

过滤器主要用于在 Web API 框架请求处理的不同级别添加额外逻辑。可用的不同类型的 Web API 过滤器如下:- 身份验证过滤器:它处理身份验证并验证 HTTP 请求。它还有助于验证用户详细信息。它检查用户的身份。
  • Authorization Filter: It handles authorization. It runs before controller action. This filter is used to check whether or not a user is authenticated. If the user is not authenticated, then it returns an HTTP status code 401 without invoking the action.
  • AuthorizeAttribute is a built-in authorization filter provided by Web API.
  • Action Filter: It is attributing that one can apply to controller action or entire controller. It is used to add extra logic before or after controller action executes. It is simply a way to add extra functionality to Web API services.
  • Exception Filter: It is used to handle exceptions that are unhandled in Web API. It is used whenever controller actions throw an unhandled exception that is not HttpResponseException. It will implement an “IExceptionFilter” interface.
  • Override Filter: It is used to exclude specific action methods or controllers from the global filter or controller level filter. It is simply used to modify the behavior of other filters for individual action methods.

349. What is XML and JSON?

什么是 XML 和 JSON?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc97f0 | 官方: 否 | 付费: 否

答案:

XML (Extensible Markup Language): - It is especially designed to store and transport data.

XML(可扩展标记语言):- 它特别设计用于存储和传输数据。
  • It is similar to HTML but is more flexible than HTML because it allows users to create their own custom tags.
  • It is used for representing structured information such as documents, data, configuration, etc.
    JSON (JavaScript Object Notation): - It is a lightweight format designed to store and transport data.

    JSON(JavaScript 对象表示法):- 它是一种轻量级格式,设计用于存储和传输数据。
  • It is easier to understand and is a standard text-based format used for representing structured data based on JavaScript object syntax.
  • It is faster and easier to use.

350. Which of the following Open-source libraries is used by WEB API for JSON serialization?

Web API 用于 JSON 序列化的以下哪个开源库?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9807 | 官方: 否 | 付费: 否

答案:

Json.NET library is generally used by Web API for JSON serialization.

Web API 通常使用 Json.NET 库进行 JSON 序列化。

351. Explain media type formatters.

解释媒体类型格式化器。
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9810 | 官方: 否 | 付费: 否

答案:

In web API, media type formatters are classes that are responsible for serialization data. Here, serialization generally means a process of translating data into a format that can be transmitted and reconstructed later. Because of serializing request/response data, Web API can understand request data format in a better way and send data in a format that the client expects. It simply specifies data that is being transferred among client and server in HTTP response or request.

在 Web API 中,媒体类型格式化器是负责序列化数据的类。这里,序列化通常意味着将数据转换为可传输并随后重建的格式的过程。由于序列化请求/响应数据,Web API 可以更好地理解请求数据的格式,并以客户端期望的格式发送数据。它简单地指定了在 HTTP 响应或请求中在客户端和服务器之间传输的数据。
Media Type Formatter Class
媒体类型格式化器类
MIME Type
MIME 类型
Description
描述
JsonMediaTypeFormatterapplication/json, text/jsonHandles JSON format
处理 JSON 格式
XmlMediaTypeFormatterapplication/xml, text/jsonHandles XML format
处理 XML 格式
FormUrlEncodedMediaTypeFormatterapplication/x-www-form-urlencodedHandles HTM form URL-encoded data
处理 HTML 表单 URL 编码数据
JQueryMvcFormUrlEncodedFormatterapplication/x-www-form-urlencodedHandles model-bound HTML form URL-encoded data
处理模型绑定的 HTML 表单 URL 编码数据

352. Why is the Web API important?

为什么 Web API 很重要?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9813 | 官方: 否 | 付费: 否

答案:

Web API is generally considered as a service that basically provides us information or data from the server. It is very important because of the following reasons: - It is used to provide an interface for websites and client applications to have access to data.

Web API 通常被视为一种服务,基本上从服务器为我们提供信息或数据。它非常重要,原因如下:- 它用于为网站和客户端应用程序提供访问数据的接口。
  • It can also be used to access data from the database and save data back to the database.
  • It supports different text formats such as XML, JSON, etc.
  • It is suitable or compatible with any type of browser and any type of device like mobile, desktop, web, etc.
  • It uses low bandwidth such as XML or JSON data, etc., and is therefore considered good for devices that have limited bandwidth such as smartphones, etc.
  • From a business point of view, web API is more applicable for UI/UX, increases interest in the company’s product and services, increases website traffic.

353. What are the main return types supported in Web API?

Web API 中支持的主要返回类型有哪些?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9817 | 官方: 否 | 付费: 否

答案:

It does not have any specific data type. It can return data of any type depending upon the business requirement. There are many HTTP methods like GET, POST, PUT, etc., which can return data in different formats depending upon the use case.

它没有特定的数据类型。它可以根据业务需求返回任何类型的数据。有许多HTTP方法,如GET、POST、PUT等,它们可以根据用例以不同格式返回数据。

354. What is the difference between Web API and WCF?

Web API和WCF之间有什么区别?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc981a | 官方: 否 | 付费: 否

答案:

WCF (Windows Communication Foundation): It is a framework used for developing SOAP (Service-oriented applications). This framework is used for developing, configuring, and deploying, or implementing network-distributed services. Web API : It is an application programming interface for both web browsers and web servers. Browser API simply extends or increases the functionality of web browsers whereas Server API simply extends or increases the functionality of web server.

WCF(Windows Communication Foundation):它是用于开发SOAP(面向服务的应用程序)的框架。该框架用于开发、配置、部署或实现网络分布式服务。Web API:它是适用于Web浏览器和Web服务器的应用程序接口。浏览器API只是扩展或增强了Web浏览器的功能,而服务器API只是扩展或增强了Web服务器的功能。
Web APIWCF
It is used to develop both SOAP-based services and RESTful services.
它用于开发基于SOAP的服务和RESTful服务。
It is used to deploy only SOAP-based services.
它仅用于部署基于SOAP的服务。
It supports various MVC features such as routing, model binding, etc.
它支持各种MVC功能,如路由、模型绑定等。
It does not support any MVC features.
它不支持任何MVC功能。
It only supports HTTP protocol.
它仅支持HTTP协议。
It supports various protocols such as HTTP, UDP, custom transport.
它支持各种协议,如HTTP、UDP、自定义传输。
It is considered best for developing RESTFUL services.
它被认为是开发RESTFUL服务的最佳选择。
It supports only limited RESTFUL services.
它仅支持有限的RESTFUL服务。
It is good when one wants to expose an expensive range of clients such as iPhones, browsers, mobile phones, tablets, etc.
当需要面向广泛的客户端(如iPhone、浏览器、手机、平板电脑等)时,它很合适。
It is good for creating services that uses expedite transport channels such as TCP, UDP, Named pipes, etc.
它适合创建使用快速传输通道(如TCP、UDP、命名管道等)的服务。
It offers support for UTF-8 encoding format.
它支持UTF-8编码格式。
It offers TEXT, Binary encoding support, MTOM (Message Transmission Optimization Mechanism), etc.
它支持TEXT、二进制编码、MTOM(消息传输优化机制)等。

355. Why to choose Web API over WCF?

为什么选择Web API而不是WCF?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc981d | 官方: 否 | 付费: 否

答案:

Web API is considered the best choice over WCF because of the following reasons: - Web API uses all features of HTTP such as URIs, request/response headers, caching, versioning, various content formats, etc.

Web API被认为是优于WCF的最佳选择,原因如下:- Web API使用HTTP的所有功能,如URI、请求/响应头、缓存、版本控制、各种内容格式等。
  • One does not have to define or explain any extra config setting for different devices in Web API.
  • Web API uses different text formats including XML because of which it is faster and more preferred for lightweight services.
  • Web API also supports MVC features whereas WCF does not support MVC features.
  • Web API provides more flexibility as compared to WCF.
  • Web API uses standard security like token authentication, basic authentication, etc., to provide secure service whereas WCF uses WS-I standard to provide secure service.

356. What are the advantages of using Rest in Web API?

在Web API中使用REST有哪些优势?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9820 | 官方: 否 | 付费: 否

答案:

REST is very important and beneficial in Web API because of the following reasons: - It allows less data transfer between client and server.

REST在Web API中非常重要且有益,原因如下:- 它允许客户端和服务器之间减少数据传输。
  • It is easy to use and lightweight.
  • It provides more flexibility.
  • It also handles and controls various types of calls, returning various data formats.
  • It is considered best for using it in mobile apps because it makes less data transfer between client and server.
  • It uses simple HTTP calls for inter-machine communication rather than using more complex options like CORBA, COM+, SOAP, or RPC.

357. Web API supports which protocol?

Web API支持哪些协议?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9823 | 官方: 否 | 付费: 否

答案:

Web API generally supports only HTTP protocol.

Web API通常仅支持HTTP协议。

358. What is Web API 2.0?

什么是Web API 2.0?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9826 | 官方: 否 | 付费: 否

答案:

It is basically an enhanced and modified feature of Web API. This new version supports various new features as given below: - New Routing Attribute

它基本上是Web API的增强和修改功能。这个新版本支持各种新功能,如下所示:- 新路由属性
  • Secure ASP.NET Web API using OAuth 2.0
  • Support for Cross-Origin requests using CORS
  • IHttpActionResult return type
  • Support for $expand, $select in OData Service
    Because of all the new features of Web API 2.0, it is considered an optimal choice and suitable development model that makes it easier to develop RESTful services interfaces to different clients running on various platforms. It also supports configuring routes in the Web API method or controller level.

    由于Web API 2.0的所有新功能,它被认为是优化选择,是适合的开发模型,使得更容易为运行在不同平台上的不同客户端开发RESTful服务接口。它还支持在Web API方法或控制器级别配置路由。

359. What is REST and SOAP? What is different between them?

什么是REST和SOAP?它们之间有什么区别?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc9829 | 官方: 否 | 付费: 否

答案:

REST (Representational State Transfer) : It is a new and improved form of web service. It describes the architectural style of networked systems. It does not require greater bandwidth when requests are sent to the server. It just includes JSON message. For example:

REST(表述性状态转移):它是一种新的、改进形式的Web服务。它描述了网络系统的架构风格。当请求发送到服务器时,它不需要更大的带宽。它仅包含JSON消息。例如:

{"city":"Mumbai","state":"Maharashtra"}

{"city":"Mumbai","state":"Maharashtra"}
SOAP (Simple Object Access Protocol) : It is a simple and lightweight protocol that is generally used for exchanging structured and typed information on the Web. It works mostly with HTTP and RPC (Remote Procedure Call). This protocol is mainly used for B2B applications one can define a data contract with it. SOAP messages are heavier in content and therefore use greater bandwidth.
SOAP(简单对象访问协议):它是一种简单且轻量级的协议,通常用于在网络上交换结构和类型化信息。它主要与HTTP和RPC(远程过程调用)配合使用。该协议主要用于B2B应用,可以定义数据契约。SOAP消息内容较重,因此占用更大带宽。

For example:

例如:

<?xml version="1.0"?>

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope" SOAP-ENV:encodingStyle=" http://www.w3.org/2001/12/soap-encoding">
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2001/12/soap-envelope" SOAP-ENV:encodingStyle=" http://www.w3.org/2001/12/soap-encoding">
<soap:Body>
<soap:Body>
<Demo.guru99WebService xmlns="http://tempuri.org/"> int
<Demo.guru99WebService xmlns="http://tempuri.org/"> int
</Demo.guru99WebService>
</Demo.guru99WebService>
</soap:Body>
</soap:Body>
</SOAP-ENV:Envelope>
</SOAP-ENV:Envelope>
| REST | SOAP |
It is basically an architectural pattern.
它基本上是一种架构模式。
It is basically a messaging protocol.
它基本上是一种消息传递协议。
It usually works with various text formats such as plain text, HTML, JSON, XML, etc.
它通常使用各种文本格式,如纯文本、HTML、JSON、XML等。
It only works with XML formats.
它仅使用XML格式。
It is totally stateless.
它完全是无状态的。
It has some specifications for both stateless and stateful implementation.
它对于无状态和有状态实现都有一些规范。
Its performance is faster as compared to SOAP.
其性能比SOAP更快。
Its performance is slower as compared to REST.
其性能比REST更慢。
It uses XML and JSON to send and receive data.
它使用XML和JSON发送和接收数据。
It uses WSDL (Web Service Description Language) for communication among consumers or users and providers.
它使用WSDL(Web服务描述语言)在消费者或用户与提供者之间进行通信。
REST has to resend transfer whenever it determines any errors.
当REST检测到任何错误时,必须重新发送传输。
SOAP includes built-in error handling for communications errors using WS-ReliableMessaging specification.
SOAP包含内置的错误处理机制,通过WS-ReliableMessaging规范处理通信错误。
It calls services using the URL path.
它通过URL路径调用服务。
It calls services by calling RPC (Remote Procedure Call) method.
它通过调用RPC(远程过程调用)方法调用服务。

360. What is different between REST API and RESTful API?

REST API和RESTful API有什么区别?
  • 知识点: 后端 (主题: api, web;标签: interviewbit, web-api, topic-specific, api, web)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9258d557c902bc982c | 官方: 否 | 付费: 否

答案:

REST (Representation State Transfer) API : It is basically an architectural style that makes productive use of existing technology and protocols of the web. It is a set of rules that developers need to follow when they develop their API or services that are scalable. It is used with HTTP protocol using its verbs such as GET, DELETE, POST, PUT. RESTful API : It is simply referred to as web services executing such as architecture.

REST(代表性状态转移)API:它基本上是一种架构风格,有效利用现有的网络技术和协议。它是开发人员在开发其API或可扩展服务时需要遵循的一组规则。它使用HTTP协议及其动词,如GET、DELETE、POST、PUT。RESTful API:它简称为执行此类架构的Web服务。
REST APIRESTful API
REST is an architectural pattern used for creating web services.
REST是用于创建Web服务的架构模式。
RESTful API is used to implement that pattern.
RESTful API用于实现该模式。
The data format of REST is based on HTTP.
REST的数据格式基于HTTP。
The data format of RESTful is based on JSON, HTTP, and Text.
RESTful的数据格式基于JSON、HTTP和文本。
Working of URL is based on request and response.
URL的工作基于请求和响应。
Working of RESTful is based on REST applications.
RESTful的工作基于REST应用。
It is more user-friendly and highly adaptable to all business enterprises and IT.
它更用户友好,且高度适应所有企业和IT环境。
It is too flexible.
它过于灵活。
It is required to develop APIs that allow interaction among clients and servers.
它需要开发API以允许客户端和服务器之间的交互。
It simply follows REST infrastructure that provides interoperability among different systems on the whole network.
它简单遵循REST基础设施,提供整个网络上不同系统之间的互操作性。

361. Explain different types of Web Services.

解释不同类型Web服务。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc997c | 官方: 否 | 付费: 否

答案:

There are basically two types of web services:

基本上有两种类型的Web服务:

SOAP (Simple Object Access Protocol) Web Services : It is also referred to as transport-independent messaging protocol whose main purpose is to transfer a message, and is based on XML protocol. RESTful (Representational State Transfer) Web Services : It is developed to fulfill the shortcomings of SOAP and to make the web services more effective.

SOAP(简单对象访问协议)Web服务:它也被称为传输无关消息传递协议,主要目的是传输消息,并基于XML协议。RESTful(代表性状态转移)Web服务:它是为了弥补SOAP的不足并使Web服务更有效而开发的。

362. What are the important features of Web services?

Web 服务的重要特性有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc997f | 官方: 否 | 付费: 否

答案:

Some of the important features of web services include: - Used to standardized XML messaging system.

Web 服务的一些重要特性包括:- 用于标准化 XML 消息传递系统。
  • Not tied to any one programming language or any operating system.
  • Discoverable via a simple find mechanism.
  • Available over the internet or private networks.
  • Supports loosely coupled connections between systems.
  • Can be synchronous or asynchronous.
  • Supports the transparent exchange of data to facilitate business integration.
  • Supports communication among different apps with HTML, XML, WSDL, SOAP, etc.
  • Supports RPC (Remote Procedure Calls).

363. What are the different components of Web Services?

Web 服务的不同组件有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9982 | 官方: 否 | 付费: 否

答案:

There are various components of web services as given below: - SOAP (Simple Object Access Protocol)

Web 服务有各种组件,如下所示:- SOAP(简单对象访问协议)
  • UDDI (Universal Description, Discovery, and Integration)
  • WSDL (Web Services Description Language)
  • RDF (Resource Description Framework)
  • XML (Extensible Markup Language)

364. Explain the term Synchronicity.

解释术语“同步性”。
  • 知识点: 后端 / 行为与软技能 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9985 | 官方: 否 | 付费: 否

答案:

Synchronicity generally refers to the binding of the client to the function’s execution and it can be done in two ways i.e., synchronous and asynchronous. In Synchronous invocations, the client blocks and waits until the service complete its operation before continuing its work. In Asynchronous invocations, clients are allowed to invoke a service and execute other functions.

同步性通常指客户端与函数执行的绑定,可以通过两种方式完成,即同步和异步。在同步调用中,客户端会阻塞并等待服务完成其操作,然后才继续自身的工作。在异步调用中,客户端可以调用服务并执行其他函数。

365. Write the difference between API and Web services.

写出 API 和 Web 服务之间的区别。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9988 | 官方: 否 | 付费: 否

答案:

API (Application Programming Interface) : It acts as an interface between two devices so that they can communicate with each other without any user intervention. Some of its features include customizable, easy integration with GUI, time effective, language-independent, etc. All APIs are not web services. Web Service : It facilitates interaction between two devices over a network. They are widely used for exchanging data among systems or applications. Some of its features include loosely coupled, supports document exchange, interoperability, extensibility, etc. All Web services are APIs.

API(应用程序编程接口):它充当两个设备之间的接口,以便它们可以在无需用户干预的情况下相互通信。其一些特性包括可定制、易于与 GUI 集成、节省时间、语言无关等。并非所有 API 都是 Web 服务。Web 服务:它促进两个设备通过网络进行交互。它们广泛用于在系统或应用程序之间交换数据。其一些特性包括松耦合、支持文档交换、互操作性、可扩展性等。所有 Web 服务都是 API。
APIWeb Service
Web 服务
It can be online or offline.
它可以在线或离线运行。
It must use a network.
它必须使用网络。
They are lightweight architecture.
它们是轻量级架构。
They require SOAP to send and receive network data therefore, are not lightweight architectures.
它们需要 SOAP 来发送和接收网络数据,因此不是轻量级架构。
It can use any design style or protocol.
它可以使用任何设计风格或协议。
It can only use SOAP but sometimes UDDI, XML, RPC, and REST also.
它只能使用 SOAP,但有时也使用 UDDI、XML、RPC 和 REST。
It supports HTTP/HTTPS protocol and also supports XML and JSON.
它支持 HTTP/HTTPS 协议,也支持 XML 和 JSON。
It supports HTTP protocol and also supports XML.
它支持 HTTP 协议,也支持 XML。
It doesn’t require any network for its operation.
它的运行不需要任何网络。
It requires a network for its operation.
它的运行需要网络。
They are open source and are used for XML.
它们是开源的,用于 XML。
They are not open source and are used to understand JSON (JavaScript Object Notation).
它们不是开源的,用于理解 JSON(JavaScript 对象表示法)。

366. Name the tools that are used to test web services.

说出用于测试 Web 服务的工具。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc998b | 官方: 否 | 付费: 否

答案:

There are various tools used to test web service as given below: - SoapUI

用于测试 Web 服务的工具有多种,如下所示:- SoapUI
  • Poster
  • Postman
  • REST client
  • JMeter

367. What is WSDL?

什么是 WSDL?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc998e | 官方: 否 | 付费: 否

答案:

WSDL (Web Services Description Language), as the name suggests, is considered the standard format that is used to describe the availability of web services and how to access them. It is based on XML protocol for exchanging data in decentralized and distributed environments. It also describes the technical details or locates the user interface to the web service. WSDL document contains some important information as given below: - Method name and parameters

WSDL(Web 服务描述语言),顾名思义,被认为是用于描述 Web 服务的可用性以及如何访问它们的标准格式。它基于 XML 协议,用于在分散和分布式环境中交换数据。它还描述了技术细节或定位 Web 服务的用户界面。WSDL 文档包含一些重要信息,如下所示:- 方法名称和参数
  • Port types
  • Service endpoint
  • Header information, etc.

368. What is XML-RPC?

什么是 XML-RPC?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9991 | 官方: 否 | 付费: 否

答案:

XML-RPC (Remote procedure call) is considered the most basic and simplest XML-based protocol to exchange data among different devices on a network. It uses HTTP as a transport protocol for quickly and easily transferring the information or data between two devices. XML-RPC can also be used with different programming languages such as Perl, Java, Python, C, C++, PHP, etc.

XML-RPC(远程过程调用)被认为是基于 XML 的最基本、最简单的协议,用于在网络中的不同设备之间交换数据。它使用 HTTP 作为传输协议,以便快速轻松地在两个设备之间传输信息或数据。XML-RPC 还可以与不同的编程语言一起使用,例如 Perl、Java、Python、C、C++、PHP 等。

369. What are the features of XML-RPC?

XML-RPC 的特性有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9994 | 官方: 否 | 付费: 否

答案:

There are various features of XML-RPC that includes: - Platform independent

XML-RPC 的各种特性包括:- 平台无关性
  • Allows diverse applications to communicate
  • Considered as the easiest and simplest way to get started with web services
  • Uses XML to encode its calls and HTTP as the transport protocol

370. What do you mean by UDDI?

UDDI 是什么意思?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc9997 | 官方: 否 | 付费: 否

答案:

UDDI (Universal Description, Discovery, and Integration) is a directory service used for describing, publishing, and finding web services. It is also used for creating business registries. It is based on a set of web standards including HTTP, XML, SOAP, WSDL, XML Schema. Its main goal is to streamline digital transactions and e-commerce among company systems.

UDDI(通用描述、发现和集成)是一种目录服务,用于描述、发布和查找 Web 服务,也用于创建企业注册中心。它基于一组 Web 标准,包括 HTTP、XML、SOAP、WSDL 和 XML Schema。其主要目标是简化公司系统之间的数字交易和电子商务。

371. What are the important features of UDDI?

UDDI 的重要特性有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc999a | 官方: 否 | 付费: 否

答案:

Some important features of UDDI include: - Platform independent

UDDI 的一些重要特性包括:- 平台无关性
  • Uses WSDL for describing interfaces to web services
  • Can communicate through SOAP, Java RMI, and CORBA Protocol
  • The delineation between interface and implementation
  • Neutral in terms of protocols

372. Name the language that is commonly used by UDDI.

说出 UDDI 常用的语言名称。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc999d | 官方: 否 | 付费: 否

答案:

The language commonly used by UDDI is WSDL (Web Service Description Language).

UDDI 常用的语言是 WSDL(Web 服务描述语言)。

373. Explain web service Architecture.

解释 Web 服务架构。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: system-design
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99a0 | 官方: 否 | 付费: 否

答案:

Every framework requires some type of architecture to ensure that the entire framework works perfectly as desired, the same goes for web services. Web service architecture is used to assist the developer with steps and procedures that are essential to complete the creation. Web service architecture includes three distinct roles i.e., service provider, service requester, and service registry. It also includes three different operations that include: Publish (Publication of Service Descriptions) : A service description needs to be published so that the service requestor can locate and have access to it. It can be published anywhere depending upon the requirements of the application. Find (Finding of Services Descriptions) : A service description is retrieved directly by a service requestor. The requestor consults the broker to locate a web service that is already published. Bind (Invoking of Service based on Service Description) : Every service needs to be invoked. To locate, contact, and invoke the service, the service requestor initiates the interaction with the service at runtime using details of binding in the service description.

每个框架都需要某种类型的架构来确保整个框架按预期完美运行,Web 服务也不例外。Web 服务架构用于协助开发者掌握完成创建所必需的步骤和流程。Web 服务架构包括三个不同的角色,即服务提供者、服务请求者和服务注册中心。它还包括三种不同的操作:发布(服务描述的发布):需要发布服务描述,以便服务请求者可以定位并访问它。根据应用需求,它可以发布在任何地方。查找(服务描述的查找):服务描述由服务请求者直接获取。请求者咨询代理以定位已发布的 Web 服务。绑定(基于服务描述调用服务):每个服务都需要被调用。为定位、联系和调用服务,服务请求者在运行时根据服务描述中的绑定细节发起与服务交互。

374. What is a Web Service Provider?

什么是 Web 服务提供者?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99a3 | 官方: 否 | 付费: 否

答案:

Web service generally creates web services and provides access to the client application who wants it. Its main purpose is to implement the service and make it available on the Internet so that client applications can use it whenever required. In simple words, it is a platform that creates and hosts web services.

Web 服务提供者通常创建 Web 服务,并向需要它的客户端应用程序提供访问。其主要目的是实现服务并在互联网上使其可用,以便客户端应用程序在需要时可以随时使用。简而言之,它是一个创建和托管 Web 服务的平台。

375. What is a Web service Requestor?

什么是 Web 服务请求者?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99a6 | 官方: 否 | 付费: 否

答案:

Web service requestor is the client application that requests for web service to use it. Its main purpose is to use an existing web service by opening a network connection and sending an XML request. In simple words, they are consumers of the web service.

Web 服务请求者是请求使用 Web 服务的客户端应用程序。其主要目的是通过打开网络连接并发送 XML 请求来使用现有 Web 服务。简而言之,他们是 Web 服务的消费者。

376. What is a Web Service Registry?

什么是 Web 服务注册中心?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99a9 | 官方: 否 | 付费: 否

答案:

The web service registry is basically like a ‘phone book’ for web services. It allows client applications to be able to publish new services or can locate the already existing ones. Two widely-used registry standards are generally supported by application servers i.e., ebXML (Electronic Business using XML) and UDDI (Universal Description, Discovery, and Integration).

Web 服务注册中心基本上就像 Web 服务的“电话簿”。它允许客户端应用程序发布新服务或定位已有的服务。应用服务器通常支持两种广泛使用的注册中心标准,即 ebXML(使用 XML 的电子商务)和 UDDI(通用描述、发现和集成)。

377. What are the different layers of the web service protocol stack?

Web 服务协议栈的不同层有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99ac | 官方: 否 | 付费: 否

答案:

The implementation of web services generally depends on technologies that are often organized in a layered stack. Examining the web service protocol stack is considered as the second option for viewing the web service architecture. In simple words, it is the set of protocols that are used to explore and execute web services. Currently, the web service protocol stack has four layers as given below:

Web 服务的实现通常依赖于经常以分层堆栈方式组织的技术。检查 Web 服务协议栈被视为查看 Web 服务架构的第二种选项。简单来说,它是用于探索和执行 Web 服务的一组协议。目前,Web 服务协议栈包含以下四个层:

Service Transport : It is generally responsible to transport messages between applications. It basically defines technology standards for communication and allows messages or information to move across the network without any difficulty. It uses HTTP, SMTP, FTP, and DEEP protocols to transfer information. XML Messaging : It is generally responsible to encode messages into XML format so that one can understand these messages at either end. This layer generally includes XML-RPC and SOAP. Service Description : It is generally responsible to describe the public interface to a specific web service. WSDL is generally used to handle service descriptions. Service Discovery : It is generally responsible to centralize service into a common registry and provides easy functionality for publishing or finding web services. UDDI is generally used to handle service discovery.

服务传输:它通常负责在应用程序之间传输消息。它基本上定义了通信的技术标准,并允许消息或信息在网络中无困难地移动。它使用 HTTP、SMTP、FTP 和 DEEP 协议来传输信息。XML 消息传递:它通常负责将消息编码为 XML 格式,以便任何一端都能理解这些消息。该层通常包括 XML-RPC 和 SOAP。服务描述:它通常负责描述特定 Web 服务的公共接口。WSDL 通常用于处理服务描述。服务发现:它通常负责将服务集中到公共注册中心,并提供发布或查找 Web 服务的简易功能。UDDI 通常用于处理服务发现。

378. What are RESTful Web Services?

什么是 RESTful Web 服务?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99af | 官方: 否 | 付费: 否

答案:

REST (Representational State Transfer) is a stateless client-server architecture style used for developing applications that are accessible over the web. It is a type of web service whose main goal is to make web services more effective. It can be defined as the web service that uses HTTP methods for implementing the REST architecture. Unlike SOAP which is protocol-based, Restful services are architecturally based. It does not contain any contract or WSDL file.

REST(表述性状态转移)是一种无状态的客户端-服务器架构风格,用于开发可通过 Web 访问的应用程序。它是一种 Web 服务,其主要目标是使 Web 服务更有效。它可以定义为使用 HTTP 方法实现 REST 架构的 Web 服务。与基于协议的 SOAP 不同,RESTful 服务基于架构。它不包含任何契约或 WSDL 文件。

379. What are the advantages of RESTful web service?

RESTful Web 服务有哪些优点?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99b2 | 官方: 否 | 付费: 否

答案:

There are several advantages of RESTful web services as given below: - Platform independent.

RESTful Web 服务有几个优点,如下所示:- 平台无关性。
  • Simple and easy to implement and test.
  • Support different formats such as JSON, XML, HTML, etc.
  • Can be written in different programming languages and executed on any platform.
  • Lightweight, manageable, scalable, and reusable.
  • Faster and provide better performance.
  • Consume less bandwidth and resources.
  • A lot of automation framework is available

380. Which protocol is used by RESTful web services?

RESTful Web 服务使用哪种协议?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99b5 | 官方: 否 | 付费: 否

答案:

The protocol used by RESTful web services is HTTP.

RESTful Web 服务使用的协议是 HTTP。

381. Explain the term statelessness with respect to RESTful web Services. Write its advantages.

解释 RESTful Web 服务中的无状态性术语。写出其优点。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99b8 | 官方: 否 | 付费: 否

答案:

Statelessness is basically a condition or restriction where RESTful web services are not allowed to keep a client state on the server as per the REST architecture. Clients are responsible to pass their context to the server. To process the client’s request, the server then further stores this context. Advantages: - No need to maintain previous interactions with clients.

无状态性基本上是一种条件或限制,根据 REST 架构,RESTful Web 服务不允许在服务器上保留客户端状态。客户端负责将其上下文传递给服务器。为了处理客户端的请求,服务器随后进一步存储此上下文。优点:- 无需维护与客户端的先前交互。
  • Independent treatment of each method request.
  • Less complexity and simplified application design.
    Example: Simple GET Request using NodeJS

    示例:使用 NodeJS 的简单 GET 请求

We have the following sample data in users.json file. Filename: users.json

我们在 users.json 文件中有以下示例数据。文件名:users.json

{
"user1" : {

"user1" : {
"name" : "gourav",
"name" : "gourav",
"password" : "password1",
"password" : "password1",
"profession" : "officer",
"profession" : "officer",
"id": 1
"id": 1
},

"user2" : {

"user2" : {
"name" : "nikhil",
"name" : "nikhil",
"password" : "password2",
"password" : "password2",
"profession" : "teacher",
"profession" : "teacher",
"id": 2
"id": 2
}
}
Implement our RESTful API listUsers using the following code in a server.js file. Filename: server.js
使用以下代码在 server.js 文件中实现我们的 RESTful API listUsers。文件名:server.js

// Requiring module

// 引用模块
var express = require('express');
var express = require('express');
var app = express();
var app = express();
var fs = require("fs");
var fs = require("fs");
// Sample GET API
// 示例 GET API
app.get('/listUsers', function (req, res) {
app.get('/listUsers', function (req, res) {
fs.readFile( __dirname + "/" + "users.json", 'utf8', function (err, data) {
fs.readFile( __dirname + "/" + "users.json", 'utf8', function (err, data) {
console.log( data );
console.log( data );
res.end( data );
res.end( data );
});
})
// Server setup
// 服务器设置
var server = app.listen(8081, function () {
var server = app.listen(8081, function () {
var host = server.address().address
var host = server.address().address
var port = server.address().port
var port = server.address().port
console.log("Example app listening at http://%s:%s", host, port)
console.log("示例应用正在监听 http://%s:%s", host, port)
})
Now open a browser and go to http://127.0.0.1:8081/listUsers , we will get the following response:
现在打开浏览器并访问 http://127.0.0.1:8081/listUsers ,我们将得到以下响应:

{
"user1" : {

"user1" : {
"name" : "gourav",
"name" : "gourav",
"password" : "password1",
"password" : "password1",
"profession" : "officer",
"profession" : "officer",
"id": 1
"id": 1
},

"user2" : {

"user2" : {
"name" : "nikhil",
"name" : "nikhil",
"password" : "password2",
"password" : "password2",
"profession" : "teacher",
"profession" : "teacher",
"id": 2
"id": 2
}
}

382. Name HTTP methods that can be used with RESTful web services.

列举可用于 RESTful Web 服务的 HTTP 方法。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99bb | 官方: 否 | 付费: 否

答案:

Some of the HTTP methods that can be used with RESTful web services include: - GET: Used to get and read a resource.

可用于 RESTful Web 服务的一些 HTTP 方法包括:- GET:用于获取和读取资源。
  • POST: Used to create a new resource.
  • PUT: Used to update existing resources.
  • DELETE: Used to delete the resource.
  • PATCH: Used to apply partial modifications to a resource.

383. What are the written status codes for REST API?

REST API 的书面状态代码有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99be | 官方: 否 | 付费: 否

答案:

REST API generally returns the following status codes in HTTP response: - 200 OK

REST API 通常在 HTTP 响应中返回以下状态代码:- 200 OK
  • 201 Created
  • 202 Accepted
  • 302 Found
  • 400 Bad Request
  • 401 Unauthorized
  • 404 Not Found
  • 405 Method Not Allowed
  • 409 Conflict
  • 500 Internal Server Error

384. What do you mean by SOAP? Write its advantages.

你所说的 SOAP 是什么意思?写出它的优点。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9458d557c902bc99c1 | 官方: 否 | 付费: 否

答案:

SOAP (Simple Object Access Protocol) is an XML-based protocol that is used to access web services. It is simply used to interchange data or information between two devices or computers using request and response based on XML format over transport protocols like HTTP, SMTP, etc.

SOAP(简单对象访问协议)是一种基于 XML 的协议,用于访问 Web 服务。它仅用于通过 HTTP、SMTP 等传输协议,基于 XML 格式的请求和响应,在两个设备或计算机之间交换数据或信息。

Advantages: - Language and Information independent.

优点:- 语言和信息无关。
  • Can be written in different programming languages or operating systems.
  • Provide data transport for web services.
  • Can extend HTTP for XML messaging.
  • Defines and uses its own WS security.
  • Easy to debug and eliminate firewall issues.

385. What are the different elements of the SOAP Document or message?

SOAP 文档或消息的不同元素有哪些?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc99c4 | 官方: 否 | 付费: 否

答案:

The SOAP message is basically an ordinary XML document consists of three parts as given below: SOAP Envelope : It is a mandatory element that identifies XML documents as a SOAP message. It simply defines the start and the end of the message. SOAP Header : It is an optional element that contains header information. SOAP Body : It is a mandatory element that contains call and response information. It includes XML data consisting of the message that is being sent.

SOAP 消息基本上是一个普通的 XML 文档,由以下三个部分组成:SOAP 信封:它是一个必需元素,用于将 XML 文档标识为 SOAP 消息。它简单定义了消息的开始和结束。SOAP 头:它是一个可选元素,包含头信息。SOAP 主体:它是一个必需元素,包含调用和响应信息。它包括包含所发送消息的 XML 数据。

The following block depicts the general structure of SOAP XML request and response:

下面的代码块描述了 SOAP XML 请求和响应的一般结构:

XML Request

XML 请求






course1
course1






XML Response
XML 响应

<SOAP-ENV:Envelope xmlns:SOAP-ENV=?http://schemas.xmlsoap.org/soap/envelope/?>;

<SOAP-ENV:Envelope xmlns:SOAP-ENV=?http://schemas.xmlsoap.org/soap/envelope/?>;
<SOAP-ENV:Header /> <!?empty header-->
<SOAP-ENV:Header /> <!?空头部-->
<SOAP-ENV:Body> <!?body begin-->
<SOAP-ENV:Body> <!?正文开始-->
<ns2:getCourseDetailsResponse xmlns:ns2=?http://in28mi>;
<ns2:getCourseDetailsResponse xmlns:ns2=?http://in28mi>;
<ns2:course>
<ns2:course>
<ns2:id>Course1</ns2:id>
<ns2:id>Course1</ns2:id>
<ns2:name>Spring<ns2:name>
<ns2:name>Spring<ns2:name>
<ns2:description>10 Steps</ns1:description>
<ns2:description>10 Steps</ns1:description>
</ns2:course>
</ns2:course>
</ns2:getCourseDetailResponse>
</ns2:getCourseDetailResponse>
</SOAP-ENV:Body> <!?body end-->
</SOAP-ENV:Body> <!?正文结束-->
</SOAP-ENV:Envelope>
</SOAP-ENV:Envelope>

386. What are the advantages of using SOA

使用 SOA 有哪些优势?
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc99cd | 官方: 否 | 付费: 否

答案:

Some of its advantages include: - Easy to integrate.

它的部分优势包括:- 易于集成。
  • Services are platform-independent.
  • Manage complexity so that integration becomes more manageable.
  • Services are easier to test and debug.
  • Easily available to any requester.

387. Name three primary security issues of Web Services?

说出Web服务的三个主要安全问题?
  • 知识点: 后端 / 行为与软技能 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc99d0 | 官方: 否 | 付费: 否

答案:

The three primary security issues of web services include: - Confidentiality

Web服务的三个主要安全问题包括:- 机密性
  • Authentication
  • Network Security

388. Name some components that are needed to be published while deploying a web service.

说出部署Web服务时需要发布的一些组件。
  • 知识点: 后端 (主题: web-services, api;标签: interviewbit, web-services, topic-specific, api)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc99d3 | 官方: 否 | 付费: 否

答案:

Components that are needed to be published while deploying a web service includes: - Web Application Directory

部署Web服务时需要发布的组件包括:- Web应用程序目录
  • Webservice.asmx File
  • Webservice.Disco File
  • Web.Config File
  • Bin Directory

389. What is an Enterprise Service Bus?

什么是企业服务总线?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a4e | 官方: 否 | 付费: 否

答案:

Software AG’s webMethods Integration Platform is an enterprise service bus solution that quickly connects all systems and applications no matter where they reside. This powerful solution offers a proven and pre-integrated software suite that makes it easy to quickly integrate systems, servers, processes, devices, partners and data.

Software AG的webMethods集成平台是一个企业服务总线解决方案,无论系统和应用程序位于何处,都能快速连接它们。这个强大的解决方案提供了一套经过验证且预集成的软件套件,使得快速集成系统、服务器、流程、设备、合作伙伴和数据变得容易。

390. List some Components of WebMethods.

列出webMethods的一些组件。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a51 | 官方: 否 | 付费: 否

答案:

WebMethods Integration platform provides components for designing, executing, and managing integration solutions. You can categorize these components as follows: - Runtime components: Run the Integration solution you developed.

webMethods集成平台提供用于设计、执行和管理集成解决方案的组件。你可以将这些组件分类如下:- 运行时组件:运行你开发的集成解决方案。
WebMethods Integration server: In webMethods, it is one of the core application servers. It's a multiplatform and Java-based enterprise integration server. Integration of diverse services, such as the conversion of data between formats and communication between systems, is supported by this component.
webMethods集成服务器:在webMethods中,它是核心应用服务器之一。它是一个多平台且基于Java的企业集成服务器。该组件支持各种服务的集成,例如格式之间的数据转换和系统之间的通信。

WebMethods Broker: It is a high-performance message router. The Publish-Subscribe Model supports both synchronous and asynchronous message-based integrations.

webMethods Broker:它是一个高性能消息路由器。发布-订阅模型支持基于消息的同步和异步集成。

WebMethods Trading networks (TN): Trading networks are an essential part of the webMethods product suite that facilitates B2B transactions. This component runs on the webMethods IS (Integration server) and allows your firm to interact with external companies, generally referring to them as partners and marketplaces, etc.

webMethods交易网络(TN):交易网络是webMethods产品套件的重要组成部分,有助于促进B2B交易。此组件运行在webMethods IS(集成服务器)上,并允许你的公司与外部公司互动,通常将它们称为合作伙伴和市场等。

WebMethods Adapters: Adapters run on webMethods IS (Integration server). These adapters connect back-end resources in the enterprise to the integration platform.

webMethods适配器:适配器运行在webMethods IS(集成服务器)上。这些适配器将企业中的后端资源连接到集成平台。

Webmethods workflow: A set of activities performed by several individuals.

webMethods工作流:由多个个体执行的一组活动。

MywebMethods Server: As a major component of the webMethods Suite, it plays a critical role in providing the UI (User Interface) framework so that customers can develop Web, portlet, and BPM (Business process management) applications. Moreover, my webMethods Server provides a central administration and monitoring platform for most of the webMethods Suite's products. - Design-time components: These components provide tools for designing and integrating solutions.

MywebMethods Server:作为webMethods套件的主要组件,它在提供UI(用户界面)框架方面扮演关键角色,使得客户能够开发Web、门户和BPM(业务流程管理)应用程序。此外,my webMethods Server为大多数webMethods套件产品提供中央管理和监控平台。- 设计时组件:这些组件提供设计和集成解决方案的工具。
WebMethods Developer: This is the IDE (Integrated development environment) that allows you to open sessions on IS (Integration server) and develop your services.
webMethods Developer:这是一个IDE(集成开发环境),允许你在IS(集成服务器)上打开会话并开发你的服务。

WebMethods workflow Designer: It is used to develop and deploy workflows. A customized Eclipse-based tool, WebMethods Designer can be used for a wide variety of purposes, including service development, CAF (Composite Application Framework) page design and coding, and deployment to the My WebMethods Server.

WebMethods 工作流设计器:用于开发和部署工作流。WebMethods Designer 是一款基于 Eclipse 的定制工具,可用于多种用途,包括服务开发、CAF(复合应用框架)页面设计和编码,以及部署到 My WebMethods Server。

WebMethods Modeler: It is a graphical tool used for designing and implementing business processes. - Administrative components: They configure the runtime environment and monitor how Integration solutions are executing on the Platform.

WebMethods 建模器:这是一种用于设计和实施业务流程的图形工具。- 管理组件:它们配置运行时环境,并监控集成解决方案在平台上的执行情况。
WebMethods Administrator: The administrator installs, configures, and maintains the WebMethods IS (Integration Server).
WebMethods 管理员:管理员负责安装、配置和维护 WebMethods IS(集成服务器)。

WebMethods Monitor: This tool allows you to view information logged by webMethods IS and webMethods Optimize.

WebMethods 监视器:此工具允许您查看由 webMethods IS 和 webMethods Optimize 记录的信息。

391. What is Integration Server in WebMethods?

什么是 WebMethods 中的集成服务器?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a54 | 官方: 否 | 付费: 否

答案:

webMethods Integration Server is one of the core application servers in the webMethods platform. It is a Java-based, multiplatform enterprise integration server. It supports the integration of diverse services, such as mapping data between formats and communication between systems.

webMethods 集成服务器是 webMethods 平台中的核心应用服务器之一。它是一个基于 Java 的多平台企业集成服务器。它支持各种服务的集成,例如在格式之间映射数据和系统之间的通信。

392. Explain UDDI (Universal, Description, Discovery and Integration).

解释 UDDI(通用描述、发现和集成)。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a57 | 官方: 否 | 付费: 否

答案:

UDDI stands for Universal, Description, Discovery, and Integration . UDDI is a platform-independent standard that describes SOA (Service Oriented Architecture) registry and its interface. By using UDDI, clients can discover registered businesses (organizations or service providers) and their web services. Furthermore, UDDI provides APIs for creating and updating registry information. UDDI defines a set of APIs that can be used to access and modify data stored in the registry. Some of these APIs are as follows: - UDDI Inquiry: Through this API, you can find registry entries and retrieve their information.

UDDI 代表通用描述、发现和集成。UDDI 是一个平台无关的标准,描述了 SOA(面向服务的架构)注册中心及其接口。通过使用 UDDI,客户端可以发现已注册的企业(组织或服务提供商)及其 Web 服务。此外,UDDI 提供了用于创建和更新注册中心信息的 API。UDDI 定义了一组 API,可用于访问和修改存储在注册中心中的数据。其中一些 API 如下:- UDDI 查询:通过此 API,您可以查找注册中心条目并检索其信息。
  • UDDI Publication: You can add new entries to the registry with this API or edit existing ones.
  • UDDI Security: It determines which security settings are applied to registry entities.

393. What are the steps to open a session on a different server?

在不同服务器上打开会话的步骤是什么?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a5a | 官方: 否 | 付费: 否

答案:

Open the Integration Server and click the 'session' menu on the toolbar. Please enter the IP address and port details for the server you wish to connect to. Enter the username and password and simply click 'Connect'.

打开集成服务器,并点击工具栏上的“会话”菜单。请输入您要连接的服务器的 IP 地址和端口详细信息。输入用户名和密码,然后只需点击“连接”。

394. How will you check memory usage?

如何检查内存使用情况?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a5d | 官方: 否 | 付费: 否

答案:

Here are two methods to check memory usage: - Top command: It provides a dynamic, real-time view of the current state of the system. You can view system information and process information, including up-time, average load, running tasks, number of logged-in users, and RAM usage. Also, you can view the processes that your users are running/using on your server.

这里有两种检查内存使用情况的方法:- Top 命令:它提供系统当前状态的动态实时视图。您可以查看系统信息和进程信息,包括运行时间、平均负载、运行任务、登录用户数和 RAM 使用情况。此外,您可以查看用户正在服务器上运行/使用的进程。
  • Free command: Top command, however, can sometimes be too much for your purposes. If all you need is to see how much memory is free and used on your system, you can use the free command.

395. State difference between a drop and delete pipeline variable.

说明丢弃和删除管道变量之间的状态差异。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9558d557c902bc9a62 | 官方: 否 | 付费: 否

答案:

Dropping a variable from Pipeline In or Pipeline Out will remove it from the pipeline. If pipeline variables aren't being used by subsequent services, they can be dropped. By removing unneeded variables, you reduce the size of the pipeline at run time, as well as the complexity of the Pipeline In and Pipeline Out displays. This can make the Pipeline view much more usable when you are working with a complicated flow. The term "drop pipeline" implies an explicit cleanup.

从“管道输入”或“管道输出”中丢弃变量会将其从管道中移除。如果后续服务未使用管道变量,则可以将其丢弃。通过移除不需要的变量,您可以减小运行时的管道大小,以及“管道输入”和“管道输出”显示的复杂性。这可以使管道视图在处理复杂流程时更加实用。术语“丢弃管道”意味着显式清理。

Delete is a design-time operation that removes a variable from the current view. It is only useful if you create a variable by mistake. When you change the view in developer after you delete a variable that was previously in the pipeline, the variable will appear again.

删除是一种设计时操作,它会从当前视图中移除变量。仅当您错误地创建了一个变量时,此操作才有用。在开发者中删除先前存在于管道中的变量后,当您更改视图时,该变量将再次出现。

396. Is it possible to change the JDK (Java Development Kit) used by Integration Server?

是否可以更改集成服务器使用的 JDK(Java 开发工具包)?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a65 | 官方: 否 | 付费: 否

答案:

To switch or change the JDK used by webMethods, you must edit IntegrationServer/bin/server.sh or IntegrationServer/bin/server.bat used to start Integration Server. Save the file after changing the JDK path as follows.

要切换或更改 webMethods 使用的 JDK,您必须编辑用于启动 Integration Server 的 IntegrationServer/bin/server.sh 或 IntegrationServer/bin/server.bat。更改 JDK 路径后按如下方式保存文件。

SET JAVA_DIR=C:\opt\j2sdk1.4.2

SET JAVA_DIR=C:\opt\j2sdk1.4.2

397. How can a service be invoked from a browser?

如何从浏览器调用服务?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a68 | 官方: 否 | 付费: 否

答案:

The 'Run in Browser' command enables you to run a service from a browser. Using this command, Designer prompts you for input values of service, creates the URL (Uniform Resource Locator) that is needed to invoke the service based on the input values you provide and passes the URL to your browser. If you use the 'Run in Browser' command to run a service, the browser (not Designer) triggers or invokes the service and receives the results. Open your browser and enter the following URL to invoke a service:

“在浏览器中运行”命令使您能够从浏览器运行服务。使用此命令时,Designer 会提示您输入服务的输入值,根据您提供的输入值创建调用服务所需的 URL(统一资源定位符),并将该 URL 传递给您的浏览器。如果您使用“在浏览器中运行”命令运行服务,则浏览器(而非 Designer)会触发或调用该服务并接收结果。打开浏览器并输入以下 URL 以调用服务:

http://servername:port/invoke/folder.subFolder.subsubFolder/serviceName

398. What is the purpose of web service connectors?

Web 服务连接器的用途是什么?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a6b | 官方: 否 | 付费: 否

答案:

When Integration Server creates consumer web service descriptors, it creates web service connectors which is a flow service. The web service connector usually contains logic and information/data required to invoke an operation specified in a WSDL (Web Service Description Language) document used to create the consumer web service descriptor.

当 Integration Server 创建消费者 Web 服务描述符时,它会创建 Web 服务连接器,这是一种流服务。Web 服务连接器通常包含调用 WSDL(Web 服务描述语言)文档中指定的操作所需的逻辑和信息/数据,这些文档用于创建消费者 Web 服务描述符。

As Integration Server creates consumer web service descriptors based on WSDL documents, it creates web service connectors for each operation the portType contains in the WSDL document. If, for example, a WSDL document contains 2 portType declarations, each of which contains 3 operations, then Integration Server creates a total of 6 web service connectors.

由于 Integration Server 基于 WSDL 文档创建消费者 Web 服务描述符,因此它会为 WSDL 文档中 portType 包含的每个操作创建 Web 服务连接器。例如,如果 WSDL 文档包含 2 个 portType 声明,每个声明包含 3 个操作,则 Integration Server 会总共创建 6 个 Web 服务连接器。

399. Describe what happens when you invoke the pub.flow:tracePipeline service and pub.flow:clearPipeline.

描述调用 pub.flow:tracePipeline 服务和 pub.flow:clearPipeline 时会发生什么。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a6e | 官方: 否 | 付费: 否

答案:

When you invoke the pub.flow:tracePipeline service, the names, and values of all pipeline fields are written to the server log. When you invoke pub.flow:clearPipeline , all pipeline fields are removed or cleared. You can specify fields that shouldn't be removed/cleared using this service.

当您调用 pub.flow:tracePipeline 服务时,所有管道字段的名称和值都会写入服务器日志。当您调用 pub.flow:clearPipeline 时,所有管道字段都会被移除或清除。您可以使用此服务指定不应被移除/清除的字段。

400. Explain the primary function of the built-in pub.flow:savePipeline service.

解释内置 pub.flow:savePipeline 服务的主要功能。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: coding
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a71 | 官方: 否 | 付费: 否

答案:

The pub.flow:savePipeline service is used to save the current pipeline to a specific location in memory on the Integration Server. Pipelines are stored in memory and can be retrieved later with the pub.flow:restorePipeline service. Pub.flow:restorePipeline service restores a pipeline that has previously been saved by pub.flow:savePipeline .

pub.flow:savePipeline 服务用于将当前管道保存到 Integration Server 内存中的特定位置。管道存储在内存中,之后可以使用 pub.flow:restorePipeline 服务检索。pub.flow:restorePipeline 服务会恢复先前由 pub.flow:savePipeline 保存的管道。

If that savePipeline is successfully invoked, a snapshot of pipeline fields will be saved under the key specified by $name. A pipeline is identified in memory by the string name "$name". If this value is not provided, an exception will be thrown.

如果 savePipeline 成功调用,管道字段的快照将保存在 $name 指定的键下。管道在内存中由字符串名称“$name”标识。如果未提供此值,则会抛出异常。

401. What is the Startup service and Shutdown service?

什么是启动服务和关闭服务?
  • 知识点: 后端 / 行为与软技能 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: behavioral | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a74 | 官方: 否 | 付费: 否

答案:

As part of the startup and shutdown services section of the Properties dialog box, you can specify what services webMethods Integration Server should automatically execute when packages are loaded into memory or unloaded from memory. - Startup Service: This displays the list of startup services a package can use, as well as the list of startup services assigned to a package. When a webMethods Integration Server loads a package into memory, it automatically executes a startup service. A startup service is useful to generate initialization files and prepare the environment (like setting up or cleaning up) before a package is loaded.

作为“属性”对话框的启动和关闭服务部分的一部分,您可以指定 webMethods Integration Server 在包加载到内存或从内存卸载时应自动执行哪些服务。- 启动服务:此显示包可以使用的启动服务列表,以及分配给包的启动服务列表。当 webMethods Integration Server 将包加载到内存时,它会自动执行启动服务。启动服务有助于生成初始化文件并在包加载前准备环境(如设置或清理)。
  • Shutdown Service: This displays the list of shutdown services a package can use, as well as the list of shutdown services assigned to a package. When a webMethods Integration Server unloads a package from memory, it automatically executes a shutdown service. Shutdown services are useful for performing cleanup tasks like closing files and cleaning temporary data. In addition, they can be used to capture state information or work-in-progress before a package is unloaded.

402. What is the process for changing the order of steps in a flow service?

更改流服务中步骤顺序的过程是什么?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a77 | 官方: 否 | 付费: 否

答案:

The arrows connecting the flow steps in the Layout tab show how (sequence) the steps are executed. It is possible to change the order that steps are executed in a flow service by moving or relocating steps. Also, a step can be relocated as a child of another step in the flow service.

“布局”选项卡中连接流步骤的箭头显示了步骤的执行顺序(顺序)。通过移动或重新定位步骤,可以更改流服务中步骤的执行顺序。此外,步骤也可以被重新定位为流服务中另一个步骤的子步骤。

Changing the sequence of steps in a flow service on the Layout tab - Click the Layout tab, then select the step whose execution order you wish to change.

在“布局”选项卡中更改流服务步骤的顺序 - 单击“布局”选项卡,然后选择您想更改执行顺序的步骤。
  • You can change the location of flow steps using the buttons, i.e., Cut, Copy, and Paste on the toolbar or in the context menu.
    Changing the sequence of steps in a flow service on the editor panel - You can change the steps by pressing the 'Shift Up' or 'Shift Down' buttons.

    在编辑器面板中更改流服务步骤的顺序 - 您可以通过按“上移”或“下移”按钮来更改步骤。
  • By pressing the 'Shift Left' and 'Shift Right' buttons, you can move a service or branch in a sequence.

403. Explain what you mean by flow service.

请解释您所说的流服务是什么意思。
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a7a | 官方: 否 | 付费: 否

答案:

Flow services are services written in the webMethods flow language. With a flow service, you can encapsulate a sequence of services into a single service and manage the data flow between them.

流服务是使用 webMethods 流语言编写的服务。通过流服务,您可以将一系列服务封装到单个服务中,并管理它们之间的数据流。

Example: Suppose, for example, you created a flow service that accepts purchase orders from buyers and executes the following series of services before submitting them to your internal ordering system:

示例:假设您创建了一个流服务,它接受来自买家的采购订单,并在将其提交到内部订购系统之前执行以下一系列服务:
  • Receives a purchase order submitted by the buyer.
  • Record the order in an audit trail.
  • Performs credit checks.
  • Posts the order in the ordering system.

404. What is the Role of a WebMethods Developer?

WebMethods 开发者的角色是什么?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a7d | 官方: 否 | 付费: 否

答案:

This is the Java-based IDE (Integrated development environment) that allows you to open sessions on WebMethods IS (Integration server) and develop your services. It is used to develop code on WebMethods IS. In addition, it also supports the development of integration applications in WebMethods Flow. Webmethod flow is a graphical programming language specially used to simplify and speed up the development of integration applications.

这是基于 Java 的 IDE(集成开发环境),允许您在 WebMethods IS(集成服务器)上打开会话并开发您的服务。它用于在 WebMethods IS 上开发代码。此外,它还支持在 WebMethods Flow 中开发集成应用程序。WebMethod flow 是一种图形化编程语言,专门用于简化和加速集成应用程序的开发。

Since version 7 of webMethods, webMethods Developer has been replaced by a new Eclipse-based IDE called webMethods Designer. As of yet, this transition has not been completed, and both products exist side by side.

自 webMethods 第 7 版以来,webMethods Developer 已被一个名为 webMethods Designer 的基于 Eclipse 的新 IDE 所取代。截至目前,这一过渡尚未完成,两种产品并存。

405. What are the modules in the WebMethods Product Suite?

WebMethods 产品套件中有哪些模块?
  • 知识点: 后端 (主题: webmethods, integration;标签: interviewbit, webmethods, topic-specific, integration)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9658d557c902bc9a80 | 官方: 否 | 付费: 否

答案:

The webMethods Product Suite comprises four modules, as follows: - Service-Oriented Architecture.

webMethods 产品套件包括四个模块,如下: - 面向服务的架构。
  • Integration and B2B (Business to Business).
  • Business Activity Monitoring.
  • Business Process Management.

406. How to increase WordPress website security?

如何提高 WordPress 网站的安全性?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c19 | 官方: 否 | 付费: 否

答案:

Despite being a safe CMS (content management system), WordPress is susceptible to attacks, just like any other CMS. WordPress security can be enhanced in many ways, as follows: - Login procedures should be secure.

尽管 WordPress 是一个安全的 CMS(内容管理系统),但它和其他 CMS 一样容易受到攻击。WordPress 的安全性可以通过多种方式增强,如下: - 登录程序应安全。
  • Consider using a secure WordPress hosting provider.
  • Update the WordPress version.
  • Upgrade the PHP version.
  • Download and install security plugins.
  • Select a secure theme for WordPress.
  • Enable SSL (Secure Socket Layer) or HTTPS (HyperText Transfer Protocol Secure) for your site.
  • Set up a firewall.
  • Make a backup of your site.
  • Manage user permissions on WordPress.
  • Change the default login URL of WordPress.
  • Disable xmlrpc.php file.
  • Disable editing files within the WordPress dashboard.
  • Modify the database file prefix.
  • Delete the default WordPress administrator account.
  • Hide the WordPress version.

407. What is WordPress?

什么是 WordPress?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c1d | 官方: 否 | 付费: 否

答案:

The WordPress content management system (CMS) is a free, open-source software application. With this tool, you can control the entire process of creating and publishing web content as well as managing their websites. You can easily manage content on your website using a content management system, even if you have no experience in programming. Therefore, WordPress makes it possible for anyone - even those who aren't developers - to build a website. Almost all web hosts support PHP and MySQL , which are used by WordPress. WordPress is a flexible CMS that can be used for virtually any type of website, including blogging, e-commerce, government, and business sites. With its flexibility and usability, WordPress is a perfect solution for large and small websites.

WordPress 内容管理系统(CMS)是一个免费、开源的软件应用程序。使用此工具,您可以控制创建和发布 Web 内容的整个过程以及管理网站。即使您没有编程经验,也能使用内容管理系统轻松管理网站上的内容。因此,WordPress 使任何人——甚至不是开发者的人——都能构建网站。几乎所有网站主机都支持 PHP 和 MySQL,这两种技术被 WordPress 使用。WordPress 是一个灵活的 CMS,可用于几乎任何类型的网站,包括博客、电子商务、政府和商业站点。凭借其灵活性和易用性,WordPress 是大型和小型网站的完美解决方案。

408. What are some of the essential features of WordPress?

WordPress 的一些基本特性是什么?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c20 | 官方: 否 | 付费: 否

答案:

The following are some of the essential features of WordPress: - Easily manage the content of your website whenever you want.

以下是 WordPress 的一些基本特性: - 随时轻松管理您网站的内容。
  • Installing and upgrading WordPress has never been a problem. A number of web hosts offer one-click installations of WordPress that let you set it up in just a few seconds.
  • Create as many pages, posts, products, and more as you want - You can upload files, text, images, links, and embed media to your pages whenever you want.
  • The WordPress platform lets you build any type of website, whether it's a personal blog or website, a portfolio, a photoblog, a business website, an online magazine, a news publication, a government website, or even an online community.
  • With WordPress, you get three default themes, but if they aren't perfect for you, you can find thousands of other themes in the theme directory.
  • WordPress has a plugin directory with thousands of plugins for every feature that isn't in the core.
  • It's easy to add, edit, or remove additional editors to allow others in your organization to manage content on your website.

409. What are WordPress Plugins?

什么是 WordPress 插件?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c23 | 官方: 否 | 付费: 否

答案:

WordPress plugins are individual pieces of software that allow you to add additional functionality to your website. All of these software pieces can be installed on your WordPress website. By using plugins, you can extend or add new functionality to your website, enabling you to easily create any type of website, from e-commerce to directories.

WordPress 插件是独立的软件片段,允许你为网站添加额外功能。所有这些软件片段都可以安装到你的 WordPress 网站上。通过使用插件,你可以扩展或添加新功能到网站,从而轻松创建任何类型的网站,从电子商务到目录。

Plugins can tweak your site in minor ways or make massive changes, depending on the features. By using a plugin, you could, for example, create a fully multilingual site or add a WhatsApp share button. Many plugins can help you add a contact form to your website, create customizable image galleries, and link to social media. You have a lot of options to choose from, both free and premium.

插件可以以细微方式调整你的网站,或进行大规模更改,具体取决于功能。例如,通过使用插件,你可以创建完全多语言的网站,或添加 WhatsApp 分享按钮。许多插件可以帮助你向网站添加联系表单、创建可自定义的图像画廊,并链接到社交媒体。你有许多选择,包括免费和付费的。

410. List some of the plugins that come with WordPress.

列出一些随 WordPress 自带的插件。
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c26 | 官方: 否 | 付费: 否

答案:

The following are the top ten most popular WordPress plugins of all time, based on actual downloads from WordPress.org. - Yoast SEO

以下是根据 WordPress.org 实际下载量统计的史上十大最受欢迎的 WordPress 插件。- Yoast SEO
  • Wordfence Security
  • Akismet
  • Contact Form 7
  • Google Analytics for WordPress
  • Jetpack
  • Elementor
  • WPForms
  • WooCommerce
  • All in One SEO Pack
  • Data Science
  • All Events
  • My Events

411. How to create a plugin in WordPress?

如何在 WordPress 中创建插件?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c2a | 官方: 否 | 付费: 否

答案:

The following steps will guide you through creating your first plugin: - Connect to your site via FTP (File Transfer Protocol).

以下步骤将指导你创建第一个插件:- 通过 FTP(文件传输协议)连接到你的网站。
  • Navigate to the WordPress plugins folder after gaining access to your site via FTP. This folder is usually located in /wp-content/plugins.
  • After you've navigated into the plugins folder, you can create a folder of your own. Create a new folder with a unique name that uses lowercase letters and dashes, for example, first_plugin. Once you've done that, choose your new folder and continue.
  • You will then need to create the main plugin file.
  • Then, create a file named very-first-plugin.php in your new plugin folder.
  • The plugin information can now be copied and pasted into your newly created main plugin file. Make sure to modify plugin details such as Plugin URL and Plugin Name.

412. What limitations does the WordPress website have?

WordPress 网站有哪些限制?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c2d | 官方: 否 | 付费: 否

答案:

The use of WordPress is not limited. Depending on your needs, it can be used for anything, from e-commerce sites to membership sites. The downsides of WordPress include: - Adding too many plugins can make the website hard to load and run.

WordPress 的使用不受限制。根据你的需求,它可以用于任何用途,从电子商务网站到会员网站。WordPress 的缺点包括:- 添加太多插件会使网站难以加载和运行。
  • Making changes or modifications to a WordPress site requires PHP knowledge.
  • It is sometimes necessary to update WordPress to keep it compatible with the latest browsers and mobile devices. Changing the version of WordPress leads to data loss, so making a backup copy is essential.
  • It is very difficult to modify or format the graphic images and tables.

413. What is required to run WordPress?

运行 WordPress 需要什么?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c30 | 官方: 否 | 付费: 否

答案:

WordPress has the following minimal requirements: - PHP version 7.2 or higher.

WordPress 有以下最低要求:- PHP 版本 7.2 或更高。
  • A MySQL version of 5.6 or higher OR a MariaDB version of 10.0 or higher.
  • Support for HTTP.
  • The best servers for running WordPress are Nginx or Apache, but any server that supports MySQL and PHP will work.

414. How many tables are there by default in WordPress?

WordPress 默认有多少张表?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c33 | 官方: 否 | 付费: 否

答案:

In WordPress databases, the shelves are called tables. By default, WordPress websites contain 12 tables. Only certain data can be stored in each table. WordPress comments tables, for example, contain information regarding IP addresses, comment author slugs, etc., of people who have commented on a post. In this way, data can be stored and retrieved more quickly.

在 WordPress 数据库中,货架被称为表。默认情况下,WordPress 网站包含 12 张表。每张表只能存储特定数据。例如,WordPress 评论表包含有关文章评论者的 IP 地址、评论作者别名等信息。这样,数据可以更快地存储和检索。

415. In WordPress, how can we change the table prefix ( wp_ )?

在 WordPress 中,我们如何更改表前缀(wp_)?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c36 | 官方: 否 | 付费: 否

答案:

You can change and rename the WordPress database prefix in several ways.

你可以通过多种方式更改和重命名 WordPress 数据库前缀。

Change the table prefix in wp-config.php

在 wp-config.php 中更改表前缀

Go to the WordPress root directory and open the wp-config.php file. Change the prefix of the table "wp_" to whatever you wish, for example, "wp_a564356_". Therefore, the line would look as follows:

转到 WordPress 根目录并打开 wp-config.php 文件。将表前缀“wp_”更改为您想要的任何内容,例如“wp_a564356_”。因此,该行将如下所示:

$table_prefix = 'wp_a564356_';

$table_prefix = 'wp_a564356_';

Change the table prefix in the database - In PhpMyAdmin, open the database.

更改数据库中的表前缀 - 在 PhpMyAdmin 中,打开数据库。
  • Select all tables that begin with the wp_ prefix.
  • Click With selected to display a drop-down menu. Select Replace table prefix from the list.
  • In the From-field, enter wp_. In the To-field, type the new name.
  • Then click Continue to make the changes.

416. What are the basic steps we should take when our WordPress website is hacked?

当我们的 WordPress 网站被黑客入侵时,我们应该采取哪些基本步骤?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c39 | 官方: 否 | 付费: 否

答案:

Since WordPress is one of the most popular CMS platforms on the web, its security is paramount. Upon analyzing the existing loopholes, standard security policies should be implemented in WordPress to protect WordPress data. The steps that must be taken when your WordPress platform is hacked are as follows: - Keep calm and seek an optimal solution.

由于 WordPress 是网络上最流行的 CMS 平台之一,其安全性至关重要。在分析现有漏洞后,应在 WordPress 中实施标准安全策略以保护 WordPress 数据。当您的 WordPress 平台被黑客入侵时必须采取的步骤如下: - 保持冷静并寻求最佳解决方案。
  • Track down the hack.
  • Contact your web hosting provider.
  • Get an InfoSec expert to help you.
  • Download and install a security plugin, such as WordPress security.
  • Locate, scan, and fix/remove malware.
  • Ensure that your access permissions are correct.
  • Also, update WordPress to its latest version.
  • Update all user IDs and passwords.
  • Check to make sure that your plugins and themes are up to date.

417. How to update the WordPress website?

如何更新 WordPress 网站?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c3c | 官方: 否 | 付费: 否

答案:

You can update your WordPress site in two simple ways: automatically and manually.

您可以通过两种简单的方式更新 WordPress 网站:自动和手动。

Automatic Method (One-click update): This is the easiest way to upgrade your WordPress version. It is as easy as clicking a button, and the installation will take only a few minutes. - Go to the WordPress admin dashboard and see if you have a new release available. To initiate the website update, click Please update now. On the Updates page, you'll need to click on the Update Now button again.

自动方法(一键更新):这是升级 WordPress 版本最简单的方法。只需点击按钮即可,安装只需几分钟。 - 转到 WordPress 管理仪表板,查看是否有新版本可用。要启动网站更新,请点击“请立即更新”。在“更新”页面上,您需要再次点击“立即更新”按钮。
  • Minor updates are indicated by a success message and options for plugin and theme updates. A welcome screen will, however, summarize what has been upgraded for major releases.
  • Now that you have updated WordPress, you can ensure that all of your themes and plugins are compatible with the new version.

Manual Method: You will need to manually upload WordPress files using FTP (File Transfer Protocol). In case the first method doesn't work, you can use this method.

手动方法:您需要使用 FTP(文件传输协议)手动上传 WordPress 文件。如果第一种方法不起作用,您可以使用这种方法。
  • Update WordPress to the latest version. Click on the Download button on the WordPress download page.
  • WordPress will now be downloaded to your browser as a zip file. Extract the zip file once it has been downloaded. There will be a WordPress folder inside, containing all the WordPress files required for the update.
  • Access your WordPress site through FileZilla or either through your preferred FTP client.
  • Look at the existing wp-admin directory and wp-includes directory on the remote side (right side of the panel) and right-click to delete/remove them.
  • Select the new wp-includes and wp-admin folders from the left-hand side of the panel (local site), then click Upload.
  • The remaining WordPress files must be uploaded from your computer to the web host directory.
  • Upload the new WordPress files to the server by overwriting the old ones.
  • Check if you've successfully completed the WordPress updates via FTP for your website by navigating to yoursite.com/wp-admin/upgrade.php/.

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

418. What do you mean by posts and pages in WordPress?

在 WordPress 中,帖子和页面是什么意思?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c3f | 官方: 否 | 付费: 否

答案:

The difference between posts and pages is that posts are more timely and regularly updated, while pages are static. It is possible to have any number of pages and posts on your website.

帖子和页面的区别在于,帖子更具时效性且定期更新,而页面是静态的。您的网站上可以有任意数量的页面和帖子。
  • WordPress Post: You can think of a WordPress post as the blog aspect of the website. In most cases, these are informational updates or news about a particular topic. It is possible to tag, categorize, and archive posts on your site. Their content is dynamic and constantly changing.
  • WordPress Pages: WordPress offers another prebuilt post type called pages. A page is similar to a post in that it has a title and body text, but it is different. In general, we add content to pages that don't need to be updated frequently. A page is similar to a post in that it has a title and body text, but it is different. Page content represents static content, such as the "About Us" page, the "TOCs", the "Contact us" page, and the "Write for Us" page.

419. Can you create custom post types in WordPress?

您能在 WordPress 中创建自定义帖子类型吗?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c42 | 官方: 否 | 付费: 否

答案:

WordPress developers are able to create custom post types. The register_post_type() function may be used to add a custom post type. Plugins allow us to create custom post types as well. - Custom Post Type UI

WordPress 开发人员能够创建自定义帖子类型。可以使用 register_post_type() 函数来添加自定义帖子类型。插件也允许我们创建自定义帖子类型。 - 自定义帖子类型 UI
  • Custom Field

420. Where is the WordPress content stored?

WordPress 内容存储在哪里?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c45 | 官方: 否 | 付费: 否

答案:

Wp_posts is a table in your MySQL database that holds the content of your WordPress posts and pages. WordPress displays your content using dynamic PHP templates, so it doesn't store a separate HTML file for each page. In the database, you can also find "Pages" (or other custom post types available in WordPress) in the wp_posts table. Typically, these can be accessed through phpMyAdmin.

Wp_posts 是您的 MySQL 数据库中的一个表,它保存您 WordPress 帖子和页面的内容。WordPress 使用动态 PHP 模板显示您的内容,因此它不会为每个页面存储单独的 HTML 文件。在数据库中,您还可以在 wp_posts 表中找到“页面”(或 WordPress 中可用的其他自定义帖子类型)。通常,这些可以通过 phpMyAdmin 访问。

421. Are deactivated plugins likely to slow down WordPress websites?

已停用的插件可能会减慢 WordPress 网站的速度吗?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c48 | 官方: 否 | 付费: 否

答案:

No, Plugins that are inactive or deactivated don't slow down WordPress. Deactivating a WordPress plugin simply turns it off. The plugin is still installed on your site, so you can activate it again if need be. Uninstalling a plugin, on the other hand, removes it from your website completely. If there are deactivated plugins preset, they will be treated as if they didn't exist. WordPress will load only the active plugins.

不,未激活或已停用的插件不会拖慢WordPress的速度。停用WordPress插件只是将其关闭。插件仍然安装在你的网站上,如果需要,你可以重新激活它。另一方面,卸载插件会将其从你的网站中完全移除。如果存在已停用的插件,它们会被视为不存在。WordPress只会加载处于激活状态的插件。

422. What is a loop in WordPress?

什么是WordPress中的循环?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c4b | 官方: 否 | 付费: 否

答案:

A PHP code for displaying WordPress posts is referred to as a loop or WordPress code. The WordPress themes display posts using a loop on the web pages of the website. These loops include functions that display the posts. One of the most important components of the WordPress code is its Loop, which contains several Template Tags for publishing, formatting, and organizing post content. By default, the WordPress loop includes the following information for each post: - Title (the_title())

用于显示WordPress文章的PHP代码被称为循环或WordPress代码。WordPress主题通过网站网页上的循环来显示文章。这些循环包含用于显示文章的函数。WordPress代码最重要的组成部分之一是其循环,其中包含多个用于发布、格式化和组织文章内容的模板标签。默认情况下,WordPress循环为每篇文章包含以下信息:- 标题(the_title())
  • Time (the_time())
  • Categories (the_category()).

423. How can comments be disabled in WordPress?

如何在WordPress中禁用评论?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c4e | 官方: 否 | 付费: 否

答案:

Disabling comments in WordPress can be done in several ways. You can disable comments in future posts, for instance.

在WordPress中禁用评论可以通过多种方式实现。例如,你可以禁用未来文章中的评论。

Navigate to admin panel -> settings -> discussion tab. Uncheck the "Allow people to post comments on new articles" option and then click on "Save Changes". By doing this, all comments on your future posts will be disabled.

导航到管理面板 -> 设置 -> 讨论选项卡。取消勾选“允许人们在新文章上发表评论”选项,然后点击“保存更改”。通过这样做,你未来文章中的所有评论都将被禁用。

424. What are config files in WordPress?

WordPress中的配置文件是什么?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c51 | 官方: 否 | 付费: 否

答案:

Wp-config.php is a core WordPress file. Information pertaining to the database is contained in this file, such as its name, username, password, and host (typically localhost).

Wp-config.php是WordPress的核心文件。关于数据库的信息包含在此文件中,例如其名称、用户名、密码和主机(通常是localhost)。

WordPress uses this information to store and retrieve data ( such as users, posts, settings, etc.) from the database. WordPress does not include the file wp-config.php in its default download package. It contains a file named wp-config-sample.php, that can be renamed to wp-config.php.

WordPress使用此信息来从数据库中存储和检索数据(如用户、文章、设置等)。WordPress的默认下载包中不包含wp-config.php文件。它包含一个名为wp-config-sample.php的文件,可以将其重命名为wp-config.php。

425. Is there any way to make other pages appear on the front page in WordPress?

有没有办法让其他页面出现在WordPress的首页上?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c54 | 官方: 否 | 付费: 否

答案:

To make your static page a front page you have to follow these steps: - Go to the Admin Panel and click on "Static Page".

要使你的静态页面成为首页,你必须遵循以下步骤:- 转到管理面板并点击“静态页面”。
  • You can select your front page in the "Front page" section.
  • From now on, your selected page will serve as your default front page.

426. Can you tell me how to create a page template?

你能告诉我如何创建页面模板吗?
  • 知识点: 后端 (主题: wordpress, cms;标签: interviewbit, wordpress, topic-specific, cms)
  • 类型: technical | 难度: easy | 子类型: concept
  • 分类: fullstack
  • id: 69b37c9958d557c902bc9c57 | 官方: 否 | 付费: 否

答案:

Creating custom templates can serve a number of purposes, such as making a different layout from the home page or displaying custom post types like news. - Add a news.php file to the theme folder.

创建自定义模板可以服务于多种目的,例如制作不同于首页的布局或显示自定义文章类型(如新闻)。- 将news.php文件添加到主题文件夹中。
  • Add the get_header() and get_footer() functions to the news.php page.
  • Add them at the top. The template name is now "News Template".

427. Do you have continuous integration?

你们有持续集成吗?
  • 知识点: 后端
  • 类型: technical | 难度: medium | 子类型:
  • 分类: general
  • id: 695a0586084cf0f0766d3eb8 | 官方: 是 | 付费: 否

答案:

The best software development teams I know use tools like Jenkins, Travis, and Buildbot. If the team has no continuous integration, I try to gauge whether they are familiar with the concept. If they aren’t, this is a bad sign in my experience. Having a continuous integration system means that the team probably believes in automation, which is usually a very good sign in my experience.

我所认识的最好的软件开发团队会使用 Jenkins、Travis 和 Buildbot 这样的工具。如果团队没有持续集成,我会试着判断他们是否熟悉这个概念。如果他们不熟悉,根据我的经验,这是一个不好的迹象。拥有持续集成系统意味着团队很可能信奉自动化,而根据我的经验,这通常是一个非常积极的信号。
For some teams, this naturally leads to a discussion about continuous delivery, which is a related but different concept from continuous integration. If it’s a web developer position, I expect the team to at least have heard about CD, and strong teams tend to put it in place, at least in part.
对某些团队来说,这自然会引出关于持续交付的讨论,持续交付是一个与持续集成相关但不同的概念。如果是 Web 开发人员职位,我期望团队至少听说过 CD,而强大的团队往往会至少部分地将其落实到位。
Follow-up questions:
后续问题:
  • When CI reports a failure, how long does your team take to get it fixed?
  • What do you like/dislike about your CI system?
  • How long do your CI runs take? Are you making them faster?

428. 静态网站(Static Website)与动态网站(Dynamic Website)有什么区别?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: static-site, dynamic-site, server-side, database)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 695cc0341da553795622a697 | 官方: 是 | 付费: 否

答案:

TL;DR静态网站内容固定,服务端通常直接返回 HTML(HyperText Markup Language)文件;动态网站会在服务端运行代码生成页面内容,常结合数据库(Database)按需返回不同结果。
静态网站(Static Website)静态网站通常使用 HTML(HyperText Markup Language)、CSS(Cascading Style Sheets)、JavaScript 构建,其内容在每次访问时不会变化。当用户请求页面时,服务器直接把 HTML(HyperText Markup Language)文件返回给浏览器展示。典型例子包括个人博客、宣传型网站、小型企业网站等。
动态网站(Dynamic Website)动态网站通常使用 Python、Java、PHP(Hypertext Preprocessor)、Ruby 等服务端语言构建,并经常使用数据库(Database)存储与检索信息。用户请求页面时,服务器会执行相应代码生成页面内容并返回给浏览器,因此可以展示随用户/数据变化的动态内容,例如股票经纪网站、社交媒体平台、内容管理系统(Content Management System)等。

429. 云计算(Cloud Computing)中的系统集成商(System Integrators)是什么?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: Integration, Hybrid Cloud, Private Cloud)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: general
  • id: 6960ca490e32007ea0d2f107 | 官方: 是 | 付费: 否

答案:

核心答案云环境(Cloud Environment)包含多组件且可能很复杂,系统集成商(System Integrator)指一套策略/过程,用于设计云架构(Cloud Architecture)并把不同组件集成起来,从而构建例如混合云(Hybrid Cloud)或私有云(Private Cloud)网络等解决方案。

430. Q9. How would you explain the API to a child?

问题9:你如何向孩子解释这个API?
  • 知识点: 后端 / 行为与软技能 (标签: explanation, simplification)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: general
  • 公司: Google
  • id: 696470f1a9243c30c87057d0 | 官方: 是 | 付费: 否

答案:

(补充答案·AI 生成(AI-Generated))

用比喻:API(Application Programming Interface,应用程序编程接口)就像餐厅的服务员——你(程序)不用进厨房(内部实现,Internal Implementation),只要按菜单(约定好的格式)告诉服务员你想要什么,他就把结果端给你。要点:①不用知道内部怎么做的;②有固定的「点单规则」(接口约定/参数,Interface Contract/Parameters);③按规则就能拿到结果,换厨师(换实现)也不影响你。

431. How would you explain the API to a child?

你会如何向一个孩子解释 API?
  • 知识点: 后端
  • 类型: technical | 难度: medium | 子类型:
  • 分类: general
  • 公司: Google
  • id: 6964718ba9243c30c87060a3 | 官方: 是 | 付费: 否

答案:

An API (Application Programming Interface) is like a waiter at a restaurant. Just like how you tell the waiter what food you want to order, a program can use an API to ask another program to do something for it. The API acts like a messenger between the two programs, taking requests from one and sending them to the other.

API(应用程序编程接口)就像餐厅里的服务员。就像你告诉服务员你想点什么食物一样,程序可以使用API来请求另一个程序为它做某事。API充当两个程序之间的信使,从一个程序接收请求并将其发送到另一个程序。
Imagine you’re playing a game on your tablet. When you tap on the screen to make the character move, your tablet is using an API to send a message to the game’s program to move the character. The API is like the waiter, taking your request and delivering it to the game program.
想象你在平板电脑上玩游戏。当你点击屏幕让角色移动时,你的平板电脑正在使用API向游戏程序发送消息以移动角色。API就像服务员一样,接收你的请求并将其传递给游戏程序。

432. 对比 MySQL 和 SQL Server(SQL Server,Structured Query Language Server)。

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: mysql, sql-server, database;标签: MySQL, SQL Server, Comparison)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965d980fa809e6d3885cbda | 官方: 是 | 付费: 否

答案:

答案标准 MySQL SQL Server(SQL Server,Structured Query Language Server)
开发者 Oracle Microsoft
编程语言 C 和 C++ 主要是 C++,但部分用 C
平台 支持多种平台 仅支持 Linux 和 Windows
语法 语法更复杂 语法更简单且更易用

433. 什么是 SQL Server(SQL Server,Structured Query Language Server)?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: sql-server, database;标签: SQL Server, DBMS)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965d980fa809e6d3885cbde | 官方: 是 | 付费: 否

答案:

答案SQL Server(SQL Server,Structured Query Language Server)是一种数据库管理系统(DBMS,Database Management System),由 Microsoft 设计。DBMS(Database Management System)是一种计算机软件应用,能够与用户、各种其他应用程序以及数据库(Database)进行交互。SQL Server(SQL Server,Structured Query Language Server)的目标是捕获并分析数据,并管理数据库(Database)的定义、查询、创建、更新以及管理工作。

434. 如何以及为什么使用 SQL Server(SQL Server,Structured Query Language Server)?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: sql-server, sql, database;标签: SQL Server, SQL)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965d980fa809e6d3885cbe3 | 官方: 是 | 付费: 否

答案:

答案SQL Server(SQL Server)是免费的,任何人都可以下载并使用。该应用使用 SQL(Structured Query Language,结构化查询语言),并且易于使用。

435. MySQL Server(MySQL Server)的默认端口是什么?

  • 知识点: 后端 / 数据库 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: mysql, sql-server, networking;标签: Port, 3306, 1433)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965d980fa809e6d3885cbf2 | 官方: 是 | 付费: 否

答案:

答案MySQL Server(MySQL Server)的默认端口是 3306。另一个标准默认端口是在 TCP/IP(TCP/IP)上用于 SQL Server(SQL Server)的 1433。
通过这个 SQL(SQL)认证课程学习所有关于 SQL(SQL)的内容!

436. 动态代理是什么?有哪些应用?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: java, spring;标签: Dynamic Proxy, AOP)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965ea17fa809e6d3887b30e | 官方: 是 | 付费: 否

答案:

答案动态代理是运行时动态生成代理类。
动态代理的应用有 spring aop(Spring AOP)、hibernate 数据查询、测试框架的后端 mock(Mock)、rpc(RPC)、Java(Java)注解对象获取等。

437. spring mvc(Spring MVC)和 struts(Struts)的区别是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, javaweb;标签: Spring MVC, Struts2)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965ea17fa809e6d3887b41f | 官方: 是 | 付费: 否

答案:

答案- 拦截级别:struts2(Struts 2)是类级别的拦截;spring mvc(Spring MVC)是方法级别的拦截。

  • 数据独立性:spring mvc 的方法之间基本上独立的,独享 request 和 response 数据,请求数据通过参数获取,处理结果通过 ModelMap 回给框架,方法之间不共享变量;而 struts2 虽然方法之间也是独立的,但其所有 action 变量是共享的,这不会影响程序运行,却给我们编码和读程序时带来了一定的麻烦。
  • 拦截机制:struts2 有自己的 interceptor 机制,spring mvc 用的是独立的 aop 方式,这样导致 struts2 的配置文件量比 spring mvc 大。
  • 对 ajax 的支持:spring mvc 集成了 ajax,所有 ajax 使用很方便,只需要一个注解@ResponseBody 就可以实现了;而 struts2 一般需要安装插件或者自己写代码才行。

438. 解释一下什么是 aop(AOP)?

  • 知识点: 后端 / UI/UX 设计 / 编程语言基础 (主题: spring, aop, java;标签: AOP, Aspect, Cross-cutting Concern)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965f11efa809e6d38885cbb | 官方: 是 | 付费: 否

答案:

答案AOP(Aspect-Oriented Programming,面向方面编程),可以说是OOP(Object-Oriented Programing,面向对象编程)的补充和完善。OOP(OOP)引入封装、继承和多态性等概念来建立一种对象层次结构,用以模拟公共行为的一个集合。当我们需要为分散的对象引入公共行为的时候,OOP(OOP)则显得无能为力。也就是说,OOP(OOP)允许你定义从上到下的关系,但并不适合定义从左到右的关系。例如日志功能。日志代码往往水平地散布在所有对象层次中,而与它所散布到的对象的核心功能毫无关系。对于其他类型的代码,如安全性、异常处理和透明的持续性也是如此。这种散布在各处的无关的代码被称为横切(cross-cutting)代码,在OOP(OOP)设计中,它导致了大量代码的重复,而不利于各个模块的重用。
而AOP(AOP)技术则恰恰相反,它利用一种称为“横切”的技术,剖解开封装的对象内部,并将那些影响了多个类的公共行为封装到一个可重用模块,并将其名为“Aspect”,即方面。所谓“方面”,简单地说,就是将那些与业务无关,却为业务模块所共同调用的逻辑或责任封装起来,便于减少系统的重复代码,降低模块间的耦合度,并有利于未来的可操作性和可维护性。AOP(AOP)代表的是一个横向的关系,如果说“对象”是一个空心的圆柱体,其中封装的是对象的属性和行为;那么面向方面编程的方法,就仿佛一把利刃,将这些空心圆柱体剖开,以获得其内部的消息。而剖开的切面,也就是所谓的“方面”了。然后它又以巧夺天功的妙手将这些剖开的切面复原,不留痕迹。
使用“横切”技术,AOP(AOP)把软件系统分为两个部分:核心关注点和横切关注点。业务处理的主要流程是核心关注点,与之关系不大的部分是横切关注点。横切关注点的一个特点是,他们经常发生在核心关注点的多处,而各处都基本相似。比如权限认证、日志、事务处理。Aop(AOP)的作用在于分离系统中的各种关注点,将核心关注点和横切关注点分离开来。正如Avanade公司的高级方案构架师Adam Magee(Adam Magee)所说,AOP(AOP)的核心思想就是“将应用程序中的商业逻辑同对其提供支持的通用服务进行分离。”

439. 解释一下什么是 ioc(IOC)?

  • 知识点: 后端 / UI/UX 设计 / 编程语言基础 (主题: spring, ioc, java;标签: IoC, DI, Inversion of Control)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6965f11efa809e6d38885cbf | 官方: 是 | 付费: 否

答案:

答案IOC是Inversion of Control的缩写,多数书籍翻译成“控制反转”。
1996年,Michael Mattson(Michael Mattson)在一篇有关探讨面向对象框架的文章中,首先提出了IOC(IOC) 这个概念。对于面向对象设计及编程的基本思想,前面我们已经讲了很多了,不再赘述,简单来说就是把复杂系统分解成相互合作的对象,这些对象类通过封装以后,内部实现对外部是透明的,从而降低了解决问题的复杂度,而且可以灵活地被重用和扩展。
IOC(Inversion of Control)理论提出的观点大体是这样的:借助于“第三方”实现具有依赖关系的对象之间的解耦。如下图:
大家看到了吧,由于引进了中间位置的“第三方”,也就是IOC(Inversion of Control)容器,使得A、B、C、D这4个对象没有了耦合关系,齿轮之间的传动全部依靠“第三方”了,全部对象的控制权全部上缴给“第三方”IOC(Inversion of Control)容器,所以,IOC(Inversion of Control)容器成了整个系统的关键核心,它起到了一种类似“粘合剂”的作用,把系统中的所有对象粘合在一起发挥作用,如果没有这个“粘合剂”,对象与对象之间会彼此失去联系,这就是有人把IOC(Inversion of Control)容器比喻成“粘合剂”的由来。
我们再来做个试验:把上图中间的IOC(Inversion of Control)容器拿掉,然后再来看看这套系统:
我们现在看到的画面,就是我们要实现整个系统所需要完成的全部内容。这时候,A、B、C、D这4个对象之间已经没有了耦合关系,彼此毫无联系,这样的话,当你在实现A的时候,根本无须再去考虑B、C和D了,对象之间的依赖关系已经降低到了最低程度。所以,如果真能实现IOC(Inversion of Control)容器,对于系统开发而言,这将是一件多么美好的事情,参与开发的每一成员只要实现自己的类就可以了,跟别人没有任何关系!
我们再来看看,控制反转(Inversion of Control,IOC)到底为什么要起这么个名字?我们来对比一下:
软件系统在没有引入IOC(Inversion of Control)容器之前,如图1所示,对象A依赖于对象B,那么对象A在初始化或者运行到某一点的时候,自己必须主动去创建对象B或者使用已经创建的对象B。无论是创建还是使用对象B,控制权都在自己手上。
软件系统在引入IOC(Inversion of Control)容器之后,这种情形就完全改变了,如图3所示,由于IOC(Inversion of Control)容器的加入,对象A与对象B之间失去了直接联系,所以,当对象A运行到需要对象B的时候,IOC(Inversion of Control)容器会主动创建一个对象B注入到对象A需要的地方。
通过前后的对比,我们不难看出来:对象A获得依赖对象B的过程,由主动行为变为了被动行为,控制权颠倒过来了,这就是“控制反转(Inversion of Control)”这个名称的由来。

440. 使用多个 DevOps(Development and Operations)工具时常见的集成挑战有哪些?如何应对?

  • 知识点: 后端 / DevOps/云 (主题: devops-tools, integration, apis, configuration;标签: Tooling, Q52, DevOps)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696601a9fa809e6d388a33f8 | 官方: 是 | 付费: 否

答案:

答案常见挑战包括:数据格式不兼容、配置冲突、工具间缺乏有效联动(例如部署工具与监控工具对接困难,或配置管理与测试工具设置不一致)。应对方式可使用集成框架/中间件/API(Application Programming Interface)来打通数据与接口、保证一致性;同时明确工具归属与协作流程,建立跨团队沟通机制,减少“各自为政”带来的摩擦。

441. 说一下你熟悉的设计模式(Design Pattern)?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: design-patterns;标签: Singleton, Factory, Observer, Facade, Template Method, State)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673756fa809e6d38a40a6c | 官方: 是 | 付费: 否

答案:

答案- 单例模式(Singleton Pattern):保证被创建一次,节省系统开销。

  • 工厂模式(简单工厂):解耦代码。
  • 观察者模式:定义了对象之间的一对多的依赖,这样一来,当一个对象改变时,它的所有的依赖者都会收到通知并自动更新。
  • 外观模式:提供一个统一的接口,用来访问子系统中的一群接口,外观定义了一个高层接口,让子系统更容易使用。
  • 模板方法模式:定义了一个算法的骨架,而将一些步骤延迟到了子类中,模板方法使得子类可以在不改变算法结构的情况下,重新定义算法的步骤。
  • 状态模式:允许对象在内部状态改变时改变它的行为,对象看起来好像修改了它的类。

442. spring(Spring Framework)有哪些主要模块?

  • 知识点: 后端 (主题: spring;标签: Spring Modules)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e71 | 官方: 是 | 付费: 否

答案:

答案- spring core(Spring Core):框架的最基础部分,提供 ioc(Inversion of Control)和依赖注入(Dependency Injection)特性。

  • spring context:构建于 core 封装包基础上的 context 封装包,提供了一种框架式的对象访问方法。
  • spring dao:Data Access Object 提供了 JDBC 的抽象层。
  • spring aop:提供了面向切面的编程实现,让你可以自定义拦截、切点等。
  • spring web:提供了针对 Web 开发的集成特性,例如文件上传,利用 servlet listeners 进行 ioc 容器初始化和针对 Web 的 ApplicationContext。
  • spring Web mvc:spring 中的 mvc 封装包提供了 Web 应用的 Model-View-Controller(MVC)的实现。

443. spring(Spring Framework)常用的注入方式有哪些?

  • 知识点: 后端 (主题: spring, di;标签: Dependency Injection)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e78 | 官方: 是 | 付费: 否

答案:

答案- setter(Setter)属性注入

  • 构造方法注入
  • 注解方式注入

444. spring 中的 bean(Bean)是线程安全的吗?

  • 知识点: 后端 / 操作系统与网络 (主题: spring, concurrency;标签: Bean, Thread Safety, Scope)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e7c | 官方: 是 | 付费: 否

答案:

答案spring 中的 bean(Bean)默认是单例模式(Singleton Pattern),spring(Spring)框架并没有对单例 bean(Bean)进行多线程的封装处理。
实际上大部分时候 spring bean(Spring Bean)无状态的(比如 dao(DAO)类),所有某种程度上来说 bean(Bean)也是安全的,但如果 bean(Bean)有状态的话(比如 view model(ViewModel)的对象),那就需要开发者自己去保证线程安全了,最简单的就是改变 bean(Bean)的作用域(Scope),把“singleton(Singleton)”变更为“prototype(Prototype)”,这样请求 bean(Bean)相当于 new Bean()了,所以就可以保证线程安全了。

  • 有状态就是有数据存储功能。
  • 无状态就是不会保存数据。

445. spring(Spring)支持几种 bean(Bean)的作用域(Scope)?

  • 知识点: 后端 (主题: spring;标签: Bean Scope, singleton, prototype, request, session, global-session)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e81 | 官方: 是 | 付费: 否

答案:

答案spring(Spring)支持 5 种作用域(Scope),如下:

  • singleton:spring ioc 容器中只存在一个 bean 实例,bean 以单例模式存在,是系统默认值;
  • prototype:每次从容器调用 bean 时都会创建一个新的示例,既每次 getBean() 相当于执行 new Bean() 操作;
  • Web 环境下的作用域:- request:每次 http 请求都会创建一个 bean;
  • session:同一个 http session 共享一个 bean 实例;
  • global-session:用于 portlet 容器,因为每个 portlet 有单独的 session,global-session 提供一个全局性的 http session。

注意:使用 prototype(Prototype)作用域(Scope)需要慎重的思考,因为频繁创建和销毁 bean(Bean)会带来很大的性能开销。

446. spring(Spring)自动装配 bean(Bean)有哪些方式?

  • 知识点: 后端 (主题: spring, di;标签: Autowire, byName, byType)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e87 | 官方: 是 | 付费: 否

答案:

答案- no:默认值,表示没有自动装配,应使用显式 bean(Bean)引用进行装配。

  • byName:它根据 bean 的名称注入对象依赖项。
  • byType:它根据类型注入对象依赖项。
  • 构造函数:通过构造函数来注入依赖项,需要设置大量的参数。
  • autodetect:容器首先通过构造函数使用 autowire 装配,如果不能,则通过 byType 自动装配。

447. spring(Spring)事务实现方式有哪些?

  • 知识点: 后端 / 数据库 (主题: spring, transactions;标签: Transaction, Declarative, Programmatic)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69673758fa809e6d38a40e8f | 官方: 是 | 付费: 否

答案:

答案- 声明式事务(Declarative Transaction):声明式事务(Declarative Transaction)也有两种实现方式,基于 xml(XML)配置文件的方式和注解方式(在类上添加 @Transaction 注解)。

  • 编码方式:提供编码的形式管理和维护事务。

448. MyBatis 如何编写一个自定义插件?

  • 知识点: 后端 / 编程语言基础 (主题: mybatis, plugin, interceptor, java;标签: MyBatis, 自定义插件, Interceptor, Executor, StatementHandler)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651c6 | 官方: 是 | 付费: 否

答案:

答案
自定义插件实现原理
MyBatis 自定义插件针对 MyBatis 四大对象(Executor、StatementHandler、ParameterHandler、ResultSetHandler)进行拦截:

  • Executor:拦截内部执行器,它负责调用 StatementHandler 操作数据库,并把结果集通过 ResultSetHandler 进行自动映射,另外它还实现了 MyBatis 的二级缓存的操作;
  • StatementHandler:拦截 SQL 语法构建的处理,它是 MyBatis 直接和数据库执行 SQL 脚本的对象,另外它也实现了 MyBatis 的一级缓存;
  • ParameterHandler:拦截参数的处理;
  • ResultSetHandler:拦截结果集的处理。

自定义插件实现关键
MyBatis 插件要实现 Interceptor 接口,接口包含的方法,如下:

public interface Interceptor {

public interface Interceptor {
Object intercept(Invocation invocation) throws Throwable;
Object intercept(Invocation invocation) throws Throwable;
Object plugin(Object target);
Object plugin(Object target);
void setProperties(Properties properties);
void setProperties(Properties properties);
}
  • setProperties 方法是在 MyBatis 进行配置插件的时候可以配置自定义相关属性,即:接口实现对象的参数配置;
  • plugin 方法是插件用于封装目标对象的,通过该方法我们可以返回目标对象本身,也可以返回一个它的代理,可以决定是否要进行拦截进而决定要返回一个什么样的目标对象,官方提供了示例: return Plugin.wrap(target, this);
  • intercept 方法就是要进行拦截的时候要执行的方法。

自定义插件实现示例
官方插件(official plugin)实现:

@Intercepts({@Signature(type = Executor.class, method = "query",

@Intercepts({@Signature(type = Executor.class, method = "query",
args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})})
public class TestInterceptor implements Interceptor {
public class TestInterceptor implements Interceptor {

public Object intercept(Invocation invocation) throws Throwable {

public Object intercept(Invocation invocation) throws Throwable {
Object target = invocation.getTarget(); //被代理对象(proxied object)
Method method = invocation.getMethod(); //代理方法(proxy method)
Object[] args = invocation.getArgs(); //方法参数(method arguments)
// do something . . . . . . 方法拦截(method interception)前执行代码块
Object result = invocation.proceed();
Object result = invocation.proceed();
// do something . . . . . . 方法拦截后执行代码块
return result;
return result;
}

public Object plugin(Object target) {

public Object plugin(Object target) {
return Plugin.wrap(target, this);
return Plugin.wrap(target, this);
}
}

449. RabbitMQ 的使用场景(use cases)有哪些?

  • 知识点: 后端 / 算法与数据结构 / 系统设计/架构 (主题: rabbitmq, message queue, distributed systems;标签: RabbitMQ, 削峰填谷, 延迟队列, 解耦)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651ca | 官方: 是 | 付费: 否

答案:

答案

  • 抢购活动,削峰填谷,防止系统崩塌。
  • 延迟信息处理,比如 10 分钟之后给下单未付款的用户发送邮件提醒。
  • 解耦系统,对于新增的功能可以单独写模块扩展,比如用户确认评价之后,新增了给用户返积分的功能,这个时候不用在业务代码里添加新增积分的功能,只需要把新增积分的接口订阅确认评价的消息队列即可,后面再添加任何功能只需要订阅对应的消息队列即可。

450. RabbitMQ 有哪些重要的角色(roles)?

  • 知识点: 后端 / 算法与数据结构 (主题: rabbitmq, message queue;标签: RabbitMQ, 生产者, 消费者, 代理)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651cf | 官方: 是 | 付费: 否

答案:

答案
RabbitMQ 中重要的角色(roles)有:生产者(producer)、消费者(consumer)和代理(broker):

  • 生产者:消息的创建者,负责创建和推送数据到消息服务器;
  • 消费者:消息的接收方,用于处理数据和确认消息;
  • 代理:就是 RabbitMQ 本身,用于扮演“快递”的角色,本身不生产消息,只是扮演“快递”的角色。

451. RabbitMQ 有哪些重要的组件(components)?

  • 知识点: 后端 / 算法与数据结构 (主题: rabbitmq, message queue;标签: RabbitMQ, Exchange, Queue, RoutingKey, BindingKey, Channel)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651d5 | 官方: 是 | 付费: 否

答案:

答案

  • ConnectionFactory(连接管理器):应用程序与 Rabbit 之间建立连接的管理器,程序代码中使用。
  • Channel(信道):消息推送使用的通道。
  • Exchange(交换器):用于接受、分配消息。
  • Queue(队列):用于存储生产者的消息。
  • RoutingKey(路由键):用于把生产者的数据分配到交换器上。
  • BindingKey(绑定键):用于把交换器的消息绑定到队列上。

452. RabbitMQ 中 vhost(virtual host)的作用是什么?

  • 知识点: 后端 / 算法与数据结构 (主题: rabbitmq, message queue;标签: RabbitMQ, vhost, 权限)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651d9 | 官方: 是 | 付费: 否

答案:

答案
vhost(virtual host):每个 RabbitMQ 都能创建很多 vhost,我们称之为虚拟主机(virtual host),每个虚拟主机其实都是 mini 版的 RabbitMQ,它拥有自己的队列(queue)、交换器(exchange)和绑定(binding),拥有自己的权限机制(permission mechanism)。

453. RabbitMQ 的消息(message)是怎么发送的?

  • 知识点: 后端 / 操作系统与网络 (主题: rabbitmq, amqp, networking;标签: RabbitMQ, TCP, AMQP, Channel)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651e0 | 官方: 是 | 付费: 否

答案:

答案
首先客户端(client)必须连接到 RabbitMQ 服务器(server)才能发布和消费消息,客户端和 rabbit server 之间会创建一个 tcp(Transmission Control Protocol)连接,一旦 tcp 打开并通过了认证(authentication)(认证就是你发送给 rabbit 服务器的用户名和密码),你的客户端和 RabbitMQ 就创建了一条 amqp(Advanced Message Queuing Protocol)信道(channel),信道是创建在“真实”的 tcp 上的虚拟连接(virtual connection),amqp 命令都是通过信道发送出去的,每个信道都会有一个唯一的 id(identifier),不论是发布消息,订阅队列都是通过这个信道完成的。

454. RabbitMQ 怎么保证消息的稳定性(stability)?

  • 知识点: 后端 (主题: rabbitmq, message reliability;标签: RabbitMQ, 事务, confirm 模式)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651e8 | 官方: 是 | 付费: 否

答案:

答案

  • 提供了事务的功能。
  • 通过将 channel 设置为 confirm(确认)模式。

455. RabbitMQ 怎么避免消息丢失(message loss)?

  • 知识点: 后端 (主题: rabbitmq, message reliability;标签: RabbitMQ, 消息丢失, 持久化)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca8fa809e6d38a651f4 | 官方: 是 | 付费: 否

答案:

答案

  • 把消息持久化磁盘,保证服务器重启消息不丢失。
  • 每个集群中至少有一个物理磁盘,保证消息落入磁盘。

456. 要保证消息持久化(Message Durability)成功的条件有哪些?

  • 知识点: 后端 (主题: rabbitmq, message reliability;标签: RabbitMQ, durable, deliveryMode, 持久化)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca9fa809e6d38a65319 | 官方: 是 | 付费: 否

答案:

答案

  • 声明队列必须设置持久化 durable 设置为 true。
  • 消息推送投递模式必须设置持久化,deliveryMode 设置为 2(持久)。
  • 消息已经到达持久化交换器。
  • 消息已经到达持久化队列。

以上四个条件都满足才能保证消息持久化(Message Durability)成功。

457. RabbitMQ 持久化(Persistence)有什么缺点?

  • 知识点: 后端 (主题: rabbitmq, performance;标签: RabbitMQ, 持久化, 吞吐量, SSD)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69674ca9fa809e6d38a65323 | 官方: 是 | 付费: 否

答案:

答案
持久化(Persistence)的缺点就是降低了服务器的吞吐量(Throughput),因为使用的是磁盘(Disk)而非内存(Memory)存储,从而降低了吞吐量(Throughput)。可尽量使用 ssd(Solid State Drive)硬盘来缓解吞吐量(Throughput)的问题。

458. RabbitMQ 有几种广播类型(Broadcast Type)?

  • 知识点: 后端 / 算法与数据结构 (主题: rabbitmq, message queue;标签: RabbitMQ, direct, headers, fanout, topic)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675100fa809e6d38a6a881 | 官方: 是 | 付费: 否

答案:

答案

  • direct(默认方式):最基础最简单的模式,发送方把消息发送给订阅方,如果有多个订阅者,默认采取轮询的方式进行消息发送。
  • headers:与 direct 类似,只是性能很差,此类型几乎用不到。
  • fanout:分发模式,把消息分发给所有订阅者。
  • topic:匹配订阅模式,使用正则匹配消息队列,能匹配到的都能接收到。

459. RabbitMQ 怎么实现延迟消息队列(Delayed Message Queue)?

  • 知识点: 后端 / 算法与数据结构 (主题: rabbitmq, message queue;标签: RabbitMQ, 延迟队列, 死信交换器, delayed-message-exchange)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675100fa809e6d38a6a89a | 官方: 是 | 付费: 否

答案:

答案
延迟队列(Delayed Queue)的实现有两种方式:

  • 通过消息过期后进入死信交换器,再由交换器转发到延迟消费队列,实现延迟功能;
  • 使用 RabbitMQ-delayed-message-exchange 插件实现延迟功能。

460. RabbitMQ 集群(Cluster)有什么用?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, 集群, 高可用, 高容量)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675100fa809e6d38a6a8a7 | 官方: 是 | 付费: 否

答案:

答案
集群(Cluster)主要有以下两个用途:

  • 高可用:某个服务器出现问题,整个 RabbitMQ 还可以继续使用;
  • 高容量:集群可以承载更多的消息量。

461. RabbitMQ 节点的类型(Node Type)有哪些?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, 磁盘节点, 内存节点)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8b5 | 官方: 是 | 付费: 否

答案:

答案

  • 磁盘节点:消息会存储到磁盘。
  • 内存节点:消息都存储在内存中,重启服务器消息丢失,性能高于磁盘类型。

462. RabbitMQ 集群(Cluster)搭建需要注意哪些问题?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, --link, erlang cookie, 磁盘节点)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8c4 | 官方: 是 | 付费: 否

答案:

答案

  • 各节点之间使用“--link”连接,此属性不能忽略。
  • 各节点使用的 erlang cookie 值必须相同,此值相当于“秘钥”的功能,用于各节点的认证。
  • 整个集群中必须包含一个磁盘节点。

463. RabbitMQ 每个节点(Node)是其他节点的完整拷贝(Full Copy)吗?为什么?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, 集群复制, 性能, 存储)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8d4 | 官方: 是 | 付费: 否

答案:

答案
不是,原因有以下两个:

  • 存储空间的考虑:如果每个节点都拥有所有队列的完全拷贝,这样新增节点不但没有新增存储空间,反而增加了更多的冗余数据;
  • 性能的考虑:如果每条消息都需要完整拷贝到每一个集群节点,那新增节点并没有提升处理消息的能力,最多是保持和单节点相同的性能甚至是更槽。

464. RabbitMQ 集群(Cluster)中唯一一个磁盘节点(Disk Node)崩溃了会发生什么情况?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, 磁盘节点, 故障)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8e5 | 官方: 是 | 付费: 否

答案:

答案
如果唯一磁盘的磁盘节点(Disk Node)崩溃了,不能进行以下操作:

  • 不能创建队列
  • 不能创建交换器
  • 不能创建绑定
  • 不能添加用户
  • 不能更改权限
  • 不能添加和删除集群节点

唯一磁盘节点(Disk Node)崩溃了,集群(Cluster)是可以保持运行的,但你不能更改任何东西。

465. RabbitMQ(Rabbit Message Queue) 对集群节点停止顺序有要求吗?

  • 知识点: 后端 / 系统设计/架构 (主题: rabbitmq, distributed systems;标签: RabbitMQ, 集群停止顺序, 消息丢失)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8f7 | 官方: 是 | 付费: 否

答案:

答案
RabbitMQ(Rabbit Message Queue) 对集群的停止的顺序是有要求的,应该先关闭内存节点,最后再关闭磁盘节点。如果顺序恰好相反的话,可能会造成消息的丢失。

466. kafka(Apache Kafka) 可以脱离 zookeeper(Apache ZooKeeper) 单独使用吗?为什么?

  • 知识点: 后端 / 系统设计/架构 (主题: kafka, zookeeper, distributed systems;标签: Kafka, ZooKeeper)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a8fc | 官方: 是 | 付费: 否

答案:

答案
kafka(Apache Kafka) 不能脱离 zookeeper(Apache ZooKeeper) 单独使用,因为 kafka(Apache Kafka) 使用 zookeeper(Apache ZooKeeper) 管理和协调 kafka(Apache Kafka) 的节点服务器。

467. kafka(Apache Kafka) 有几种数据保留的策略?

  • 知识点: 后端 / 系统设计/架构 (主题: kafka, distributed systems;标签: Kafka, 数据保留, retention)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a902 | 官方: 是 | 付费: 否

答案:

答案
kafka(Apache Kafka) 有两种数据保存策略:按照过期时间保留和按照存储的消息大小保留。

468. kafka(Apache Kafka) 同时设置了 7 天和 10G 清除数据,到第五天的时候消息达到了 10G,这个时候 kafka(Apache Kafka) 将如何处理?

  • 知识点: 后端 / 系统设计/架构 (主题: kafka, distributed systems;标签: Kafka, 清理策略, retention)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a906 | 官方: 是 | 付费: 否

答案:

答案
这个时候 kafka(Apache Kafka) 会执行数据清除工作,时间和大小不论那个满足条件,都会清空数据。

469. 什么情况会导致 kafka(Apache Kafka) 运行变慢?

  • 知识点: 后端 (主题: kafka, performance;标签: Kafka, 性能瓶颈, CPU, 磁盘IO, 网络)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a90d | 官方: 是 | 付费: 否

答案:

答案

  • cpu 性能瓶颈
  • 磁盘读写瓶颈
  • 网络瓶颈

470. 使用 kafka(Apache Kafka) 集群需要注意什么?

  • 知识点: 后端 / 系统设计/架构 (主题: kafka, distributed systems;标签: Kafka, 集群规模, 复制, 容错)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a915 | 官方: 是 | 付费: 否

答案:

答案

  • 集群的数量不是越多越好,最好不要超过 7 个,因为节点越多,消息复制需要的时间就越长,整个群组的吞吐量就越低。
  • 集群数量最好是单数,因为超过一半故障集群就不能用了,设置为单数容错率更高。

471. zookeeper(Apache ZooKeeper) 是什么?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, 协调服务, 一致性)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a91a | 官方: 是 | 付费: 否

答案:

答案
zookeeper(Apache ZooKeeper) 是一个分布式的、开放源码的分布式应用程序协调服务,是 google chubby(Google Chubby) 的开源实现,是 hadoop(Apache Hadoop) 和 hbase(Apache HBase) 的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。

472. zookeeper(Apache ZooKeeper) 都有哪些功能?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, 主节点选举, 分布式锁, 命名服务)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a920 | 官方: 是 | 付费: 否

答案:

答案

  • 集群管理:监控节点存活状态、运行请求等。
  • 主节点选举:主节点挂掉了之后可以从备用的节点开始新一轮选主,主节点选举说的就是这个选举的过程,使用 zookeeper 可以协助完成这个过程。
  • 分布式锁:zookeeper 提供两种锁:独占锁、共享锁。独占锁即一次只能有一个线程使用资源,共享锁是读锁共享,读写互斥,即可以有多条线程同时读取一个资源,如果要使用写锁也只能有一个线程使用。 zookeeper 可以对分布式锁进行控制。
  • 命名服务:在分布式系统中,通过使用命名服务,客户端应用能够根据指定名字来获取资源或服务的地址,提供者等信息。

473. zookeeper(Apache ZooKeeper) 有几种部署模式?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, 部署模式, 伪集群)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a927 | 官方: 是 | 付费: 否

答案:

答案
zookeeper(Apache ZooKeeper) 有三种部署模式:

  • 单机部署:一台集群上运行;
  • 集群部署:多台集群运行;
  • 伪集群部署:一台集群启动多个 zookeeper 实例运行。

474. zookeeper(Apache ZooKeeper) 怎么保证主从节点的状态同步?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, ZAB, 原子广播, 状态同步)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675101fa809e6d38a6a92f | 官方: 是 | 付费: 否

答案:

答案
zookeeper(ZooKeeper) 的核心是原子广播(atomic broadcast),这个机制保证了各个 server(服务器) 之间的同步。实现这个机制的协议叫做 zab 协议(ZAB protocol)。zab 协议有两种模式,分别是恢复模式(recovery mode)(选主)和广播模式(broadcast mode)(同步)。当服务启动或者在领导者(leader) 崩溃后,zab 就进入了恢复模式,当领导者被选举出来,且大多数 server 完成了和 leader 的状态同步以后,恢复模式就结束了。状态同步保证了 leader 和 server 具有相同的系统状态。

475. 集群中有 3 台服务器,其中一个节点宕机,这个时候 zookeeper(ZooKeeper) 还可以使用吗?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, 容错, quorum)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675102fa809e6d38a6aa54 | 官方: 是 | 付费: 否

答案:

答案
可以继续使用,单数服务器只要没超过一半的服务器宕机就可以继续使用。

476. 说一下 zookeeper(ZooKeeper) 的通知机制?

  • 知识点: 后端 / 系统设计/架构 (主题: zookeeper, distributed systems;标签: ZooKeeper, watcher, 通知机制, znode)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675102fa809e6d38a6aa5d | 官方: 是 | 付费: 否

答案:

答案
客户端端会对某个 znode(Znode) 建立一个 watcher(Watcher) 事件,当该 znode 发生变化时,这些客户端会收到 zookeeper(ZooKeeper) 的通知,然后客户端可以根据 znode 变化来做出业务上的改变。

477. 数据库的三范式(Three Normal Forms) 是什么?

  • 知识点: 后端 / 数据库 (主题: mysql, database;标签: 数据库范式, 1NF, 2NF, 3NF)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675103fa809e6d38a6abac | 官方: 是 | 付费: 否

答案:

答案

  • 第一范式:强调的是列的原子性,即数据库表的每一列都是不可分割的原子数据项。
  • 第二范式:要求实体的属性完全依赖于主关键字。所谓完全依赖是指不能存在仅依赖主关键字一部分的属性。
  • 第三范式:任何非主属性不依赖于其它非主属性。

478. 一张自增表里面总共有 7 条数据,删除了最后 2 条数据,重启 MySQL 数据库,又插入了一条数据,此时 id 是几?

  • 知识点: 后端 / 数据库 (主题: mysql, database;标签: MySQL, 自增ID, MyISAM, InnoDB)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675103fa809e6d38a6abb0 | 官方: 是 | 付费: 否

答案:

答案

  • 表类型如果是 MyISAM,那 id 就是 8。
  • 表类型如果是 InnoDB,那 id 就是 6。

InnoDB(InnoDB) 表会把自增主键的最大 id 记录在内存中,所以重启之后会导致最大 id 丢失。

479. 如何获取当前数据库版本?

  • 知识点: 后端 / 数据库 (主题: mysql, sql;标签: MySQL, version(), SQL)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675104fa809e6d38a6acdc | 官方: 是 | 付费: 否

答案:

答案
使用 select version()(SELECT VERSION()) 获取当前 MySQL 数据库版本。

480. 说一下 ACID(ACID) 是什么?

  • 知识点: 后端 / 数据库 (主题: database, mysql;标签: ACID, 事务, 原子性, 一致性, 隔离性, 持久性)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675104fa809e6d38a6ace1 | 官方: 是 | 付费: 否

答案:

答案

  • Atomicity(原子性):一个事务(transaction)中的所有操作,或者全部完成,或者全部不完成,不会结束在中间某个环节。事务在执行过程中发生错误,会被恢复(Rollback)到事务开始前的状态,就像这个事务从来没有执行过一样。即,事务不可分割、不可约简。
  • Consistency(一致性):在事务开始之前和事务结束以后,数据库的完整性没有被破坏。这表示写入的资料必须完全符合所有的预设约束、触发器、级联回滚等。
  • Isolation(隔离性):数据库允许多个并发事务同时对其数据进行读写和修改的能力,隔离性可以防止多个事务并发执行时由于交叉执行而导致数据的不一致。事务隔离分为不同级别,包括读未提交(Read uncommitted)、读提交(read committed)、可重复读(repeatable read)和串行化(Serializable)。
  • Durability(持久性):事务处理结束后,对数据的修改就是永久的,即便系统故障也不会丢失。

481. float(FLOAT) 和 double(DOUBLE) 的区别是什么?

  • 知识点: 后端 / 数据库 (主题: mysql, database;标签: MySQL, float, double)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675104fa809e6d38a6acea | 官方: 是 | 付费: 否

答案:

答案

  • float 最多可以存储 8 位的十进制数,并在内存中占 4 字节。
  • double 最多可以存储 16 位的十进制数,并在内存中占 8 字节。

482. MySQL 的内连接(inner join)、左连接(left join)、右连接(right join) 有什么区别?

  • 知识点: 后端 / 数据库 (主题: mysql, sql;标签: MySQL, JOIN, inner join, left join, right join)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675104fa809e6d38a6acf9 | 官方: 是 | 付费: 否

答案:

答案
内连接关键字:inner join(INNER JOIN);左连接:left join(LEFT JOIN);右连接:right join(RIGHT JOIN)。

内连接是把匹配的关联数据显示出来;左连接是左边的表全部显示出来,右边的表显示出符合条件的数据;右连接正好相反。

483. MySQL 索引(index) 是怎么实现的?

  • 知识点: 后端 / 数据库 (主题: mysql, database, index;标签: MySQL, 索引, B+树)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753e8fa809e6d38a734ab | 官方: 是 | 付费: 否

答案:

答案
索引(Index)是满足某种特定查找算法的数据结构(Data Structure),而这些数据结构会以某种方式指向数据,从而实现高效查找数据。

具体来说 MySQL 中的索引(Index),不同的数据库引擎(Database Engine)实现有所不同,但目前主流的数据库引擎的索引都是 B+ 树(B+ Tree)实现的,B+ 树的搜索效率,可以到达二分法(Binary Search)的性能,找到数据区域之后就找到了完整的数据结构了,所以索引的性能也是更好的。

484. 怎么验证 MySQL 的索引(Index)是否满足需求?

  • 知识点: 后端 / 数据库 (主题: mysql, sql, index;标签: MySQL, EXPLAIN, 索引验证)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753e8fa809e6d38a734c2 | 官方: 是 | 付费: 否

答案:

答案
使用 explain(执行计划)查看 SQL 是如何执行查询语句的,从而分析你的索引是否满足需求。

explain(执行计划)语法: explain select * from table where type=1。

485. 说一下数据库的事务隔离(Transaction Isolation)?

  • 知识点: 后端 / 数据库 (主题: mysql, database, transaction;标签: MySQL, 事务隔离, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753e9fa809e6d38a735f1 | 官方: 是 | 付费: 否

答案:

答案
MySQL 的事务隔离是在 MySQL.ini 配置文件里添加的,在文件的最后添加:

transaction-isolation = REPEATABLE-READ

transaction-isolation = REPEATABLE-READ
可用的配置值: READ-UNCOMMITTED(读未提交)、 READ-COMMITTED(读已提交)、 REPEATABLE-READ(可重复读)、 SERIALIZABLE(串行化)。
  • READ-UNCOMMITTED:未提交读,最低隔离级别,事务未提交前,就可被其他事务读取(会出现幻读、脏读、不可重复读)。
  • READ-COMMITTED:提交读,一个事务提交之后才能被其他事务读取到(会造成幻读、不可重复读)。
  • REPEATABLE-READ:可重复读,默认级别,保证多次读取同一个数据时,其值都和事务开始时候的内容是一致,禁止读取到别的事务未提交的数据(会造成幻读)。
  • SERIALIZABLE:序列化,代价最高最可靠的隔离级别,该隔离级别能防止脏读、不可重复读、幻读。

脏读(Dirty Read):表示一个事务(Transaction)能够读取另一个事务中还未提交的数据。比如,某个事务尝试插入记录 A,此时该事务还未提交,然后另一个事务尝试读取到了记录 A。

不可重复读(Non-repeatable Read):是指在一个事务内,多次读取同一数据。

幻读(Phantom Read):指同一个事务内多次查询返回的结果集不一样。比如同一个事务 A 第一次查询时候有 n 条记录,但是第二次同等条件下查询却有 n+1 条记录,这就好像产生了幻觉。发生幻读的原因也是另外一个事务新增或者删除或者修改了第一个事务结果集里面的数据,同一个记录的数据内容被修改了,所有数据行的记录就变多或者变少了。

486. 说一下 MySQL 常用的引擎(Engine)?

  • 知识点: 后端 / 数据库 (主题: mysql, database;标签: MySQL, InnoDB, MyISAM, 存储引擎)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753e9fa809e6d38a73603 | 官方: 是 | 付费: 否

答案:

答案

  • InnoDB 引擎:InnoDB 引擎提供了对数据库 acid 事务的支持,并且还提供了行级锁和外键的约束。它的设计的目标就是处理大数据容量的数据库系统。MySQL 运行的时候,InnoDB 会在内存中建立缓冲池,用于缓存数据和索引。但是该引擎是不支持全文搜索,同时启动也比较的慢,它是不会保存表的行数的,所以当进行 select count(*) from table 指令的时候,需要进行扫描全表。由于锁的粒度小,写操作是不会锁全表的,所以在并发度较高的场景下使用会提升效率的。
  • MyISAM 引擎:MySQL 的默认引擎,但不提供事务的支持,也不支持行级锁和外键。因此当执行插入和更新语句时,即执行写操作的时候需要锁定这个表,所以会导致效率会降低。不同于 InnoDB 不同的是,MyISAM 引擎是保存了表的行数,于是当进行 select count(*) from table 语句时,可以直接的读取出保存的值而不需要进行扫描全表。所以,如果表的读操作远多于写操作时,并且不需要事务的支持的,可以将 MyISAM 作为数据库引擎的首选。

487. 说一下 MySQL 的行锁(Row Lock)和表锁(Table Lock)?

  • 知识点: 后端 / 数据库 (主题: mysql, database, locking;标签: MySQL, 行锁, 表锁, InnoDB, MyISAM)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753e9fa809e6d38a73616 | 官方: 是 | 付费: 否

答案:

答案
MyISAM 只支持表锁(Table Lock),InnoDB 支持表锁和行锁(Row Lock),默认为行锁。

  • 表级锁:开销小,加锁快,不会出现死锁。锁定粒度大,发生锁冲突的概率最高,并发量最低。
  • 行级锁:开销大,加锁慢,会出现死锁。锁力度小,发生锁冲突的概率小,并发度最高。

488. 说一下乐观锁(Optimistic Lock)和悲观锁(Pessimistic Lock)?

  • 知识点: 后端 / 数据库 (主题: database, locking;标签: 乐观锁, 悲观锁, version)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a7373b | 官方: 是 | 付费: 否

答案:

答案

  • 乐观锁:每次去拿数据的时候都认为别人不会修改,所以不会上锁,但是在提交更新的时候会判断此期间别人有没有去更新这个数据。
  • 悲观锁:每次去拿数据的时候都认为别人会修改,所以每次在拿数据的时候都会上锁,这样别人想拿这个数据就会阻止,直到这个锁被释放。

数据库的乐观锁需要自己实现,在表里面添加一个 version(版本号)字段,每次修改成功值加 1,这样每次修改的时候先对比一下,自己拥有的 version 和数据库现在的 version 是否一致,如果不一致就不修改,这样就实现了乐观锁。

489. MySQL(My Structured Query Language)问题排查都有哪些手段?

  • 知识点: 后端 / 数据库 / 操作系统与网络 (主题: mysql, sql, performance;标签: MySQL, processlist, EXPLAIN, 慢查询日志)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a7374f | 官方: 是 | 付费: 否

答案:

答案

  • 使用 show processlist 命令查看当前所有连接信息。
  • 使用 explain 命令查询 SQL 语句执行计划。
  • 开启慢查询日志,查看慢查询的 SQL。

490. 如何做 MySQL(My Structured Query Language)的性能优化?

  • 知识点: 后端 / 数据库 (主题: mysql, database, performance;标签: MySQL, 性能优化, 索引, 分表, 存储引擎)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a73764 | 官方: 是 | 付费: 否

答案:

答案

  • 为搜索字段创建索引。
  • 避免使用 select *,列出需要查询的字段。
  • 垂直分割分表。
  • 选择正确的存储引擎。

491. Redis(Remote Dictionary Server)是什么?都有哪些使用场景?

  • 知识点: 后端 / 数据库 / 系统设计/架构 (主题: redis, cache;标签: Redis, 缓存, 会话, 计数)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a7376c | 官方: 是 | 付费: 否

答案:

答案
Redis(Remote Dictionary Server)是一个使用 C 语言开发的高速缓存数据库。

Redis(Remote Dictionary Server)使用场景:

  • 记录帖子点赞数、点击数、评论数;
  • 缓存近期热帖;
  • 缓存文章详情信息;
  • 记录用户会话信息。

492. Redis(Remote Dictionary Server)有哪些功能?

  • 知识点: 后端 / 数据库 / 系统设计/架构 (主题: redis, cache, distributed systems;标签: Redis, 持久化, 事务, 分布式锁, 消息队列)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a73774 | 官方: 是 | 付费: 否

答案:

答案

  • 数据缓存功能
  • 分布式锁的功能
  • 支持数据持久化
  • 支持事务
  • 支持消息队列

493. Redis(Remote Dictionary Server)和 memcache(Memory Cache)有什么区别?

  • 知识点: 后端 / 数据库 / 系统设计/架构 (主题: redis, memcached, cache;标签: Redis, Memcached, 区别, 持久化, 数据类型)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a73780 | 官方: 是 | 付费: 否

答案:

答案

  • 存储方式不同:memcache 把数据全部存在内存之中,断电会挂掉,数据不能超过内存大小;Redis 有部份存在硬盘上,这样能保证数据的持久性。
  • 数据支持类型:memcache 对数据类型支持相对简单;Redis 有复杂的数据类型。
  • 使用底层模型不同:它们之间底层实现方式,以及与客户端之间通信的应用协议不一样,Redis 自己构建了 vm 机制,因为一般的系统调用系统函数的话,会浪费一定的时间去移动和请求。
  • value 值大小不同:Redis 最大可以达到 1gb;memcache 只有 1mb。

494. Redis(Remote Dictionary Server)为什么是单线程的?

  • 知识点: 后端 / 数据库 (主题: redis, performance;标签: Redis, 单线程, 性能瓶颈)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753eafa809e6d38a7379d | 官方: 是 | 付费: 否

答案:

答案
因为 cpu(Central Processing Unit)不是 Redis(Remote Dictionary Server)的瓶颈,Redis(Remote Dictionary Server)的瓶颈最有可能是机器内存或者网络带宽。既然单线程容易实现,而且 cpu(Central Processing Unit)又不会成为瓶颈,那就顺理成章地采用单线程的方案了。

关于 Redis(Remote Dictionary Server)的性能,官方网站也有,普通笔记本轻松处理每秒几十万的请求。

而且单线程并不代表就慢 nginx(Engine X)和 nodejs(Node.js)也都是高性能单线程的代表。

495. Redis(Remote Dictionary Server)支持的数据类型有哪些?

  • 知识点: 后端 / 数据库 / 算法与数据结构 (主题: redis;标签: Redis, 数据类型, string, list, hash, set, zset)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753ecfa809e6d38a738d7 | 官方: 是 | 付费: 否

答案:

答案
Redis(Remote Dictionary Server)支持的数据类型: string(String,字符串)、 list(List,列表)、 hash(Hash,字典)、 set(Set,集合)、 zset(Sorted Set,有序集合)。

496. Redis(Remote Dictionary Server)支持的 Java 客户端都有哪些?

  • 知识点: 后端 / 数据库 / 编程语言基础 (主题: redis, java;标签: Redis, Java客户端, Redisson, Jedis, Lettuce)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753ecfa809e6d38a738de | 官方: 是 | 付费: 否

答案:

答案
支持的 Java 客户端有 Redisson、jedis(Jedis)、lettuce(Lettuce)等。

497. jedis(Jedis)和 Redisson 有哪些区别?

  • 知识点: 后端 / 数据库 / 编程语言基础 (主题: redis, java;标签: Redis, Jedis, Redisson, 客户端对比)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753ecfa809e6d38a738e2 | 官方: 是 | 付费: 否

答案:

答案

  • jedis:提供了比较全面的 Redis 命令的支持。
  • Redisson:实现了分布式和可扩展的 Java 数据结构,与 jedis 相比,Redisson 的功能相对简单,不支持排序、事务、管道、分区等 Redis 特性。

498. Redis(Remote Dictionary Server)持久化(Persistence)有几种方式?

  • 知识点: 后端 / 数据库 (主题: redis, persistence;标签: Redis, 持久化, RDB, AOF)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753edfa809e6d38a73a18 | 官方: 是 | 付费: 否

答案:

答案
Redis(Remote Dictionary Server)的持久化(Persistence)有两种方式,或者说有两种策略:

  • RDB(Redis Database):指定的时间间隔能对你的数据进行快照存储。
  • AOF(Append Only File):每一个收到的写命令都通过 write 函数追加到文件中。

499. Redis(Remote Dictionary Server)如何做内存优化(Memory Optimization)?

  • 知识点: 后端 / 数据库 (主题: redis, performance;标签: Redis, 内存优化, hash)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753edfa809e6d38a73a39 | 官方: 是 | 付费: 否

答案:

答案
尽量使用 Redis(Remote Dictionary Server)的散列表(Hash Table),把相关的信息放到散列表里面存储,而不是把每个字段单独存储,这样可以有效的减少内存使用。比如将 Web(World Wide Web)系统的用户对象,应该放到散列表里面整体存储到 Redis(Remote Dictionary Server),而不是把用户的姓名、年龄、密码、邮箱等字段分别设置 key(键)进行存储。

500. Redis(Remote Dictionary Server)淘汰策略(Eviction Policy)有哪些?

  • 知识点: 后端 / 数据库 / 系统设计/架构 (主题: redis, cache;标签: Redis, 淘汰策略, LRU, TTL)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753edfa809e6d38a73a46 | 官方: 是 | 付费: 否

答案:

答案

  • volatile-lru:从已设置过期时间的数据集(server.db[i].expires)中挑选最近最少使用的数据淘汰。
  • volatile-ttl:从已设置过期时间的数据集(server.db[i].expires)中挑选将要过期的数据淘汰。
  • volatile-random:从已设置过期时间的数据集(server.db[i].expires)中任意选择数据淘汰。
  • allkeys-lru:从数据集(server.db[i].dict)中挑选最近最少使用的数据淘汰。
  • allkeys-random:从数据集(server.db[i].dict)中任意选择数据淘汰。
  • no-enviction(驱逐):禁止驱逐数据。

501. Redis(Remote Dictionary Server)常见的性能问题(Performance Issue)有哪些?该如何解决?

  • 知识点: 后端 / 数据库 (主题: redis, performance, replication;标签: Redis, 性能问题, 快照, 主从复制, 局域网)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753edfa809e6d38a73a54 | 官方: 是 | 付费: 否

答案:

答案

  • 主服务器写内存快照,会阻塞主线程的工作,当快照比较大的对性能影响是非常大的,会间断性暂停服务,所以主服务器最好不要写内存快照。
  • Redis 主从复制的性能问题,为了主从复制的速度和连接的稳定性,主从库最好在同一个局域网内。

502. 说一下 JVM(Java Virtual Machine)的主要组成部分?及其作用?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, java;标签: JVM, ClassLoader, Runtime Data Area, Execution Engine, Native Interface)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696753edfa809e6d38a73a59 | 官方: 是 | 付费: 否

答案:

答案

  • 类加载器(ClassLoader)
  • 运行时数据区(Runtime Data Area)
  • 执行引擎(Execution Engine)
  • 本地库接口(Native Interface)

组件的作用:首先通过类加载器(ClassLoader)会把 Java 代码转换成字节码(Bytecode),运行时数据区(Runtime Data Area)再把字节码加载到内存中,而字节码文件只是 JVM(Java Virtual Machine)的一套指令集规范,并不能直接交给底层操作系统去执行,因此需要执行引擎(Execution Engine),将字节码翻译成底层系统指令,再交由 CPU(Central Processing Unit)去执行,而这个过程中需要调用其他语言的本地库接口(Native Interface)来实现整个程序的功能。

503. 说一下 JVM(Java Virtual Machine)运行时数据区(Runtime Data Area)?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, java, runtime;标签: JVM, 运行时数据区, Java Heap, Method Area)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675706fa809e6d38a7cc47 | 官方: 是 | 付费: 否

答案:

答案
不同虚拟机的运行时数据区可能略微有所不同,但都会遵从 Java 虚拟机规范(Java Virtual Machine Specification),Java 虚拟机规范规定的区域分为以下 5 个部分:

  • 程序计数器(Program Counter Register):当前线程所执行的字节码的行号指示器,字节码解释器的工作是通过改变这个计数器的值,来选取下一条需要执行的字节码指令,分支、循环、跳转、异常处理、线程恢复等基础功能,都需要依赖这个计数器来完成;
  • Java 虚拟机栈(Java Virtual Machine Stacks):用于存储局部变量表、操作数栈、动态链接、方法出口等信息;
  • 本地方法栈(Native Method Stack):与虚拟机栈的作用是一样的,只不过虚拟机栈是服务 Java 方法的,而本地方法栈是为虚拟机调用 Native 方法服务的;
  • Java 堆(Java Heap):Java 虚拟机中内存最大的一块,是被所有线程共享的,几乎所有的对象实例都在这里分配内存;
  • 方法区(Methed Area):用于存储已被虚拟机加载的类信息、常量、静态变量、即时编译后的代码等数据。

504. 什么是双亲委派模型(Parent Delegation Model)?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, java, classloader;标签: JVM, ClassLoader, 双亲委派, Bootstrap, ApplicationClassLoader)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675711fa809e6d38a7d628 | 官方: 是 | 付费: 否

答案:

答案
在介绍双亲委派模型(Parent Delegation Model)之前先说下类加载器(ClassLoader)。对于任意一个类,都需要由加载它的类加载器和这个类本身一同确立在 JVM(Java Virtual Machine)中的唯一性,每一个类加载器,都有一个独立的类名称空间。类加载器就是根据指定全限定名称(Fully Qualified Name)将 class 文件加载到 JVM 内存,然后再转化为 class 对象。

类加载器(ClassLoader)分类:

  • 启动类加载器(Bootstrap ClassLoader),是虚拟机自身的一部分,用来加载 Java_HOME/lib/目录中的,或者被 -Xbootclasspath 参数所指定的路径中并且被虚拟机识别的类库;
  • 其他类加载器:
  • 扩展类加载器(Extension ClassLoader):负责加载 lib\ext 目录或 Java.ext.dirs 系统变量指定的路径中的所有类库;
  • 应用程序类加载器(Application ClassLoader):负责加载用户类路径(classpath)上的指定类库,我们可以直接使用这个类加载器。一般情况下,如果我们没有自定义类加载器默认就是用这个加载器。

双亲委派模型(Parent Delegation Model):如果一个类加载器收到了类加载的请求,它首先不会自己去加载这个类,而是把这个请求委派给父类加载器去完成,每一层的类加载器都是如此,这样所有的加载请求都会被传送到顶层的启动类加载器中,只有当父加载器无法完成加载请求(它的搜索范围中没找到所需的类)时,子加载器才会尝试去加载类。

505. 说一下类装载(Class Loading)的执行过程?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, java, classloader;标签: JVM, 类加载, 加载验证准备解析初始化)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675713fa809e6d38a7d78c | 官方: 是 | 付费: 否

答案:

答案
类装载(Class Loading)分为以下 5 个步骤:

  • 加载:根据查找路径找到相应的 class 文件然后导入;
  • 检查:检查加载的 class 文件的正确性;
  • 准备:给类中的静态变量分配内存空间;
  • 解析:虚拟机将常量池中的符号引用替换成直接引用的过程。符号引用就是理解为一个标示,而在直接引用直接指向内存中的地址;
  • 初始化:对静态变量和静态代码块执行初始化工作。

506. 怎么判断对象是否可以被回收(Garbage Collection)?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, gc, java;标签: GC, 引用计数, 可达性分析, GC Roots)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675714fa809e6d38a7d8d2 | 官方: 是 | 付费: 否

答案:

答案
一般有两种方法来判断:

  • 引用计数器:为每个对象创建一个引用计数,有对象引用时计数器 +1,引用被释放时计数 -1,当计数器为 0 时就可以被回收。它有一个缺点不能解决循环引用的问题;
  • 可达性分析:从 GC Roots 开始向下搜索,搜索所走过的路径称为引用链。当一个对象到 GC Roots 没有任何引用链相连时,则证明此对象是可以被回收的。

507. Java 中都有哪些引用类型(Reference Type)?

  • 知识点: 后端 / 编程语言基础 (主题: java, jvm, gc;标签: Java引用, StrongReference, SoftReference, WeakReference, PhantomReference)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675714fa809e6d38a7d902 | 官方: 是 | 付费: 否

答案:

答案

  • 强引用:发生 gc 的时候不会被回收。
  • 软引用:有用但不是必须的对象,在发生内存溢出之前会被回收。
  • 弱引用:有用但非必须的对象,在下一次 GC 时会被回收。
  • 虚引用(幽灵引用/幻影引用):无法通过虚引用获得对象,用 PhantomReference 实现虚引用,虚引用的用途是在 gc 时返回一个通知。

508. 说一下 JVM(Java Virtual Machine) 有哪些垃圾回收算法(Garbage Collection Algorithm)?

  • 知识点: 后端 (主题: jvm, gc;标签: GC算法, 标记清除, 标记整理, 复制, 分代)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675714fa809e6d38a7d909 | 官方: 是 | 付费: 否

答案:

答案

  • 标记-清除算法:标记无用对象,然后进行清除回收。缺点:效率不高,无法清除垃圾碎片。
  • 标记-整理算法:标记无用对象,让所有存活的对象都向一端移动,然后直接清除掉端边界以外的内存。
  • 复制算法:按照容量划分二个大小相等的内存区域,当一块用完的时候将存活的对象复制到另一块上,然后再把已使用的内存空间一次清理掉。缺点:内存使用率不高,只有原来的一半。
  • 分代算法:根据对象存活周期的不同将内存划分为几块,一般是新生代和老年代,新生代基本采用复制算法,老年代采用标记整理算法。

509. 说一下 JVM(Java Virtual Machine) 有哪些垃圾回收器(Garbage Collector)?

  • 知识点: 后端 (主题: jvm, gc;标签: GC收集器, Serial, ParNew, Parallel, CMS, G1)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675714fa809e6d38a7d911 | 官方: 是 | 付费: 否

答案:

答案

  • Serial:最早的单线程串行垃圾回收器。
  • Serial Old:Serial 垃圾回收器的老年代版本,同样也是单线程的,可以作为 CMS 垃圾回收器的备选预案。
  • ParNew:是 Serial 的多线程版本。
  • Parallel:和 ParNew 收集器类似是多线程的,但 Parallel 是吞吐量优先的收集器,可以牺牲等待时间换取系统的吞吐量。
  • Parallel Old:是 Parallel 老年代版本,Parallel 使用的是复制的内存回收算法,Parallel Old 使用的是标记-整理的内存回收算法。
  • CMS:一种以获得最短停顿时间为目标的收集器,非常适用 B/S 系统。
  • G1:一种兼顾吞吐量和停顿时间的 GC 实现,是 JDK 9 以后的默认 GC 选项。

510. 新生代垃圾回收器(Young Generation Garbage Collector)和老生代垃圾回收器(Old Generation Garbage Collector)都有哪些?有什么区别?

  • 知识点: 后端 (主题: jvm, gc;标签: 新生代GC, 老年代GC, 复制算法, 标记整理, G1)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675716fa809e6d38a7dcca | 官方: 是 | 付费: 否

答案:

答案

  • 新生代回收器:Serial、ParNew、Parallel Scavenge
  • 老年代回收器:Serial Old、Parallel Old、CMS
  • 整堆回收器:G1

新生代垃圾回收器(Young Generation Garbage Collector)一般采用的是复制算法(Copying Algorithm),复制算法的优点是效率高,缺点是内存利用率低;老年代回收器(Old Generation Garbage Collector)一般采用的是标记-整理(Mark-Compact)的算法进行垃圾回收。

511. 常用的 JVM(Java Virtual Machine) 调优的参数都有哪些?

  • 知识点: 后端 / 编程语言基础 (主题: jvm, gc, java;标签: JVM参数, GC日志, 堆大小, CMS, ParNew)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69675719fa809e6d38a7e29a | 官方: 是 | 付费: 否

答案:

答案

  • -Xms2g:初始化堆大小为 2g;
  • -Xmx2g:堆最大内存为 2g;
  • -XX:NewRatio=4:设置年轻的和老年代的内存比例为 1:4;
  • -XX:SurvivorRatio=8:设置新生代 Eden 和 Survivor 比例为 8:2;
  • -XX:+UseParNewGC:指定使用 ParNew + Serial Old 垃圾回收器组合;
  • -XX:+UseParallelOldGC:指定使用 ParNew + ParNew Old 垃圾回收器组合;
  • -XX:+UseConcMarkSweepGC:指定使用 CMS + Serial Old 垃圾回收器组合;
  • -XX:+PrintGC:开启打印 gc 信息;
  • -XX:+PrintGCDetails:打印 gc 详细信息。

512. spring mvc(Spring Model-View-Controller) 工作流程是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, spring-mvc;标签: Spring MVC, DispatcherServlet, Workflow)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69685279fa809e6d38b9facb | 官方: 是 | 付费: 否

答案:

答案- 用户发请求到前端控制器(Front Controller) DispatcherServlet

  • DispatcherServlet 收到请求调用 HandlerMapping 处理器映射器。
  • 处理器映射器根据请求url找到具体的处理器,生成处理器对象及处理器拦截器(如果有)一并返回给DispatcherServlet.
  • DispatcherServlet 通过 HandlerAdapter 处理器适配器调用处理器。
  • 执行处理器(Controller,也叫后端控制器)。
    Controller(控制器)执行完成返回 ModelAndView(模型和视图)
    HandlerAdapter(处理器适配器)将controller执行结果 ModelAndView(模型和视图) 返回给 DispatcherServlet(前端控制器)
    DispatcherServlet(前端控制器)将 ModelAndView(模型和视图) 传给 ViewResolver(视图解析器)
    ViewResolver(视图解析器) 解析后返回具体 View(视图)
    DispatcherServlet(前端控制器) 对 View(视图) 进行渲染视图(即渲染(Render)时将模型数据填充到视图中)。
    DispatcherServlet(前端控制器) 响应用户。

513. hibernate(Hibernate) 是如何工作的?

  • 知识点: 后端 (主题: hibernate, orm;标签: Hibernate, 工作流程)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696896b7bc0b9904d6b7d32d | 官方: 是 | 付费: 否

答案:

答案

  • 读取并解析配置文件。
  • 读取并解析映射文件,创建 SessionFactory。
  • 打开 Session。
  • 创建事务。
  • 进行持久化操作。
  • 提交事务。
  • 关闭 Session。
  • 关闭 SessionFactory。

514. get() 和 load() 的区别?

  • 知识点: 后端 (主题: hibernate, orm;标签: Hibernate, get, load)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696896b7bc0b9904d6b7d330 | 官方: 是 | 付费: 否

答案:

答案

  • 数据查询时,没有 OID 指定的对象,get() 返回 null;load() 返回一个代理对象。
  • load() 支持延迟加载;get() 不支持延迟加载。

515. 说一下 hibernate(Hibernate) 的缓存机制?

  • 知识点: 后端 / 系统设计/架构 (主题: hibernate, cache;标签: Hibernate, 一级缓存, 二级缓存, EhCache)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696896b7bc0b9904d6b7d334 | 官方: 是 | 付费: 否

答案:

答案
hibernate(Hibernate) 常用的缓存有一级缓存(First-level Cache)和二级缓存(Second-level Cache):

一级缓存(First-level Cache):也叫 Session(Session)缓存,只在 Session(Session)作用范围内有效,不需要用户干涉,由 hibernate(Hibernate)自身维护,可以通过:evict(evict)(object)清除 object 的缓存;clear()清除一级缓存中所有的缓存;flush()刷出缓存;

二级缓存:应用级别的缓存,在所有 Session 中都有效,支持配置第三方的缓存,如:EhCache(Ehcache)。

516. hibernate(Hibernate) 对象有哪些状态?

  • 知识点: 后端 (主题: hibernate, orm;标签: Hibernate, 对象状态)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696896b7bc0b9904d6b7d339 | 官方: 是 | 付费: 否

答案:

答案

  • 临时/瞬时状态:直接 new 出来的对象,该对象还没被持久化(没保存在数据库中),不受 Session 管理。
  • 持久化状态:当调用 Session 的 save/saveOrupdate/get/load/list 等方法的时候,对象就是持久化状态。
  • 游离状态:Session 关闭之后对象就是游离状态。

517. 在 hibernate(Hibernate) 中 getCurrentSession 和 openSession 的区别是什么?

  • 知识点: 后端 (主题: hibernate, spring;标签: Hibernate, Session, getCurrentSession, openSession)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69689779bc0b9904d6b7e0c2 | 官方: 是 | 付费: 否

答案:

答案

  • getCurrentSession 会绑定当前线程,而 openSession 则不会。
  • getCurrentSession 事务是 Spring 控制的,并且不需要手动关闭,而 openSession 需要我们自己手动开启和提交事务。

518. hibernate(Hibernate) 实体类必须要有无参构造函数吗?为什么?

  • 知识点: 后端 / 编程语言基础 (主题: hibernate, java, reflection;标签: Hibernate, 无参构造函数, 反射)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69689779bc0b9904d6b7e0cb | 官方: 是 | 付费: 否

答案:

答案
hibernate(Hibernate) 中每个实体类必须提供一个无参构造函数,因为 hibernate(Hibernate)框架要使用 reflection api(Reflection API),通过调用 ClassnewInstance()来创建实体类的实例,如果没有无参的构造函数就会抛出异常。

519. MyBatis 中 #{} 和 ${} 的区别是什么?

  • 知识点: 后端 / 数据库 / 编程语言基础 (主题: mybatis, sql, java;标签: MyBatis, #{}, ${}, SQL 注入)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69689779bc0b9904d6b7e0d7 | 官方: 是 | 付费: 否

答案:

答案
\#{} 是预编译处理(Prepared Statement),${} 是字符替换(String Substitution)。

在使用 #{} 时, MyBatis(MyBatis) 会将 SQL(SQL) 中的 #{} 替换成“?”,配合 PreparedStatement(PreparedStatement) 的 set 方法赋值,这样可以有效的防止 SQL 注入(SQL Injection),保证程序的运行安全。

520. MyBatis(MyBatis) 有几种分页方式?

  • 知识点: 后端 / 数据库 (主题: mybatis, database;标签: MyBatis, 分页, RowBounds, PageHelper)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6968982ebc0b9904d6b7f637 | 官方: 是 | 付费: 否

答案:

答案
分页方式:逻辑分页(Logical Pagination)和物理分页(Physical Pagination)。

逻辑分页(Logical Pagination):使用 MyBatis(MyBatis) 自带的 RowBounds(RowBounds) 进行分页,它是一次性查询很多数据,然后在数据中再进行检索。

物理分页(Physical Pagination):自己手写 SQL 分页或使用分页插件 PageHelper,去数据库查询指定条数的分页数据的形式。

521. RowBounds 是一次性查询全部结果吗?为什么?

  • 知识点: 后端 (主题: mybatis, jdbc, performance;标签: MyBatis, RowBounds, Fetch Size)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6968982ebc0b9904d6b7f63a | 官方: 是 | 付费: 否

答案:

答案
RowBounds 表面是在所有数据中检索数据,其实并不是一次性查询出所有数据,因为 MyBatis 是对 JDBC 的封装,在 JDBC 驱动中有一个 Fetch Size 的配置,它只定义了每次最多从数据库查询多少条数据,假如你要查询更多数据,它会在你执行 next()的时候,去查询更多的数据。就好比你去自动取款机取 10000 元,但取款机每次最多能取 2500 元,所以你要取 4 次才能把钱取完。只是对于 JDBC 来说,当你调用 next()的时候会自动帮你完成查询工作并帮你缓存好数据,所以可以有效的防止内存溢出(OutOfMemoryError)。

Fetch Size 官方相关文档(Fetch Size Official Documentation):http://t.cn/EFsE2g3

522. MyBatis 逻辑分页(Logical Paging)和物理分页(Physical Paging)的区别是什么?

  • 知识点: 后端 / 数据库 (主题: mybatis, database, performance;标签: MyBatis, 逻辑分页, 物理分页)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6968982ebc0b9904d6b7f63f | 官方: 是 | 付费: 否

答案:

答案

  • 逻辑分页是一次性查询很多数据,然后再在结果中检索分页的数据。这样做弊端是需要消耗大量的内存,有内存溢出的风险,对数据库压力较大。
  • 物理分页是从数据库查询指定条数的数据,弥补了一次性查出所有数据的种种缺点,比如需要大量的内存,对数据库压力较大等问题。

523. 你能写一段高效的代码来统计文件中大写字母(Uppercase Letters)的数量吗?

  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 (主题: python;标签: file, string, generator-expression)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6969ab723695832c6e08a2e6 | 官方: 是 | 付费: 否

答案:

答案这个问题的常规解法如下:
with open(SOME_LARGE_FILE) as countletter:

with open(SOME_LARGE_FILE) as countletter:
count = 0
count = 0
text = countletter.read()
text = countletter.read()
for character in text:
for character in text:
if character.isupper():
if character.isupper():
count += 1为了让代码更高效,可以使用“生成器表达式(Generator Expression)”把整段代码改写成一行。对应的一行代码如下:
count sum(1 for line in countletter for character in line if character.isupper())
计算每行中大写字母数量的总和(count sum(1 for line in countletter for character in line if character.isupper()))

524. Python 的 Flask 如何处理数据库请求(Database Requests)?

  • 知识点: 后端 / 数据库 / 编程语言基础 (主题: python, flask;标签: flask, database, request-lifecycle)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6969af563695832c6e0917b9 | 官方: 是 | 付费: 否

答案:

答案Flask 支持基于数据库的应用(Relational Database Systems,RDBS)。这类系统需要先创建 schema,这通常需要把 schema.sql 文件通过管道(Piping)传给 sqlite3 命令。因此,为了在 Flask 中创建或初始化数据库,需要安装 sqlite3 命令。
Flask 允许通过三种方式请求数据库:

  • before_request():在请求之前被调用,不传任何参数。
  • after_request():在请求之后被调用,并传入将发送给客户端的 response。
  • teardown_request():当抛出异常且无法保证 response 时被调用。它在 response 构建完成后执行;不允许修改 request,返回值会被忽略。

525. 在该设计里,更新玩家分数的 API 应该如何设计?需要考虑哪些状态码(Status Codes)语义?

  • 知识点: 后端 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, api, security;标签: REST, status code, leaderboard)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dd4b4e6ae93548e9479d6 | 官方: 是 | 付费: 否

答案:

答案可采用 REST:POST /players/:player-id/scores,携带 JWT 鉴权(JWT Authentication)与 JSON 负载(JSON Payload)(player_id、score、location 等)。同步成功返回 200;若采用异步写入(进入队列/流处理)可返回 202;请求体非法返回 400;凭证有效但无权限返回 403。关键是保证鉴权、幂等策略(Idempotency Strategy)(必要时引入 request_id)与限流(Rate Limiting)防刷分。

526. 为什么在系统里需要健康检查(Health Check)接口?HEAD vs GET 有什么取舍?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, observability, api;标签: health check, HEAD, reliability)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dd4b6e6ae93548e947bb4 | 官方: 是 | 付费: 否

答案:

答案健康检查用于负载均衡(Load Balancing)与编排系统(Orchestration System)(K8s/ASG)判断实例是否可接流量。HEAD 只返回响应头,不返回 body,带宽更省、执行路径更短,适合高频探活;GET 可携带更丰富诊断信息但更重。通常对外提供轻量 HEAD /:service/health,内部再配一个受控的详细诊断端点(Diagnostic Endpoint)。

527. 系统设计面试中如何设计 API 与通信协议(Communication Protocol)?REST、GraphQL、RPC 怎么选?

  • 知识点: 后端 / 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, architecture, scalability, reliability;标签: api, rest, graphql, grpc, websocket)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddc00e6ae93548e957e20 | 官方: 是 | 付费: 否

答案:

答案API(Application Programming Interface)设计要先从“系统要对外提供什么能力”出发,再决定API(Application Programming Interface)风格与协议(Protocol)。关键是:接口要清晰、语义一致、便于演进。
步骤建议- 列出能力:用户要完成哪些动作(创建/查询/更新/删除/订阅)。

  • 选择风格:- REST:资源模型清晰、调试方便、生态成熟,适合公开 API。
  • GraphQL:前端按需取字段,减少 over-fetch/under-fetch,适合复杂聚合查询。
  • RPC/gRPC:内部服务调用高性能、强契约,但耦合更紧、调试相对难。
  • 定义 Endpoint:路径命名统一、HTTP 方法语义正确(GET/POST/PUT/PATCH/DELETE)。
  • 数据格式:常用 JSON;必要时考虑 Protobuf(配合 gRPC)。
  • 通信协议:HTTPS(通用)、WebSocket(实时双向)、SSE(服务端推送)、消息协议(AMQP/MQTT)用于异步。
    加分点:提到鉴权(JWT(JSON Web Token)/OAuth(Open Authorization))、版本管理(/v1)、幂等性(Idempotency)、分页(Pagination)与限流(Rate Limiting)策略。

528. 什么是URL Shortener(短链服务)?它解决了什么问题,典型使用场景有哪些?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: intro, use-cases)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9ae6ae93548e95c09f | 官方: 是 | 付费: 否

答案:

答案URL Shortener(短链服务)把一条很长的原始链接(URL)转换成更短、更易分享的唯一别名(Alias),用户访问短链时会被重定向(Redirect)回原链接。它主要解决社交平台字符限制、链接可读性差、营销/渠道追踪困难等问题。
常见场景- 社交媒体/短信:用短链节省字符并提升分享体验。

  • 营销投放:不同渠道生成不同短链做点击归因与统计。
  • 产品内跳转:统一入口,便于后续替换落地页。
  • 品牌化链接:支持自定义别名(如 /promo2026)。

529. 设计短链系统时,功能性需求(Functional Requirements)和非功能性需求(Non-functional Requirements)分别要覆盖哪些点?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: requirements, functional, non-functional)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9de6ae93548e95c26d | 官方: 是 | 付费: 否

答案:

答案需求阶段要把“必须做什么”和“做到什么程度”分开说清楚。
功能性需求(Functional Requirements)- 为长链接生成唯一短链。

  • 访问短链时重定向到原链接。
  • 可选:自定义短链别名(custom alias)。
  • 可选:链接过期(expiration),到期不可访问。
  • 可选:访问统计(analytics),如点击次数、来源、地域等。
    非功能性需求(Non-functional Requirements)- 高可用(High Availability):例如 99.9% uptime(正常运行时间),避免短链失效。
  • 低延迟:生成与重定向毫秒级。
  • 可扩展:能支撑百万/亿级请求增长。
  • 持久性:短链要稳定可用多年。
  • 安全:防滥用/钓鱼/恶意跳转,配合风控与审核。

530. 短链系统如何做容量评估?给定 100 万/天写入、读写比(Read-to-Write Ratio)100:1、峰值 10 倍,该怎么算QPS(Queries Per Second)和存储?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: capacity, qps, storage)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9de6ae93548e95c270 | 官方: 是 | 付费: 否

答案:

答案容量评估的目标是把“感觉很大”变成可计算的吞吐(Throughput)与存储(Storage),从而决定是否需要缓存(Cache)、分片(Sharding)和多地域部署(Multi-region Deployment)。
吞吐(Throughput)- 平均写入:1,000,000 / 86,400 ≈ 12 WPS(Writes Per Second)

  • 峰值写入:12 × 10 = 120 WPS
  • 平均重定向:12 × 100 = 1,200 RPS
  • 峰值重定向:120 × 100 = 12,000 RPS
    存储(Storage)若每条映射记录约:短链 7B(Bytes) + 原链接 100B + 创建/过期时间 16B + 点击数 4B ≈ 127B。
  • 一年写入量:1,000,000 × 365 = 365,000,000
  • 一年存储:365,000,000 × 127B ≈ 46.4GB(不含索引与冗余)
    结论:这是典型读多写少系统,重定向(Redirect)链路要优先低延迟(Latency),缓存(Cache)能明显减轻数据库(Database)压力。

531. 短链系统为什么强烈建议用缓存(Cache)?如何用 80/20 规则(80/20 Rule)估算缓存大小与DB(Database)命中?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: cache, redis, 80-20)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9de6ae93548e95c273 | 官方: 是 | 付费: 否

答案:

答案短链重定向是高频读请求,任何一次 DB(Database)查询都会增加延迟与成本,所以缓存(Cache)能直接提升体验并降低数据库压力。
用 80/20 估算假设 20% 热门短链贡献 80% 读流量;每日新增 100 万条映射,每条约 127B(Bytes)。

  • 缓存 20%:1,000,000 × 0.2 × 127B ≈ 25.4MB
    若缓存命中率(Cache Hit Rate)90%,则只有 10% 重定向会打到 DB:
  • DB RPS ≈ 1,200 × 0.10 = 120 RPS
    落地建议- Cache key:short_key → long_url + metadata(过期时间等)。
  • 策略:LRU/LFU + 过期 TTL(与短链过期对齐)。
  • 保护:防穿透(Bloom Filter/negative cache)、防击穿(互斥锁/请求合并)。

532. 短链系统的高层架构(High-Level Architecture)应该包含哪些核心组件?每个组件负责什么?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: architecture, components)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c473 | 官方: 是 | 付费: 否

答案:

答案高层设计要围绕两条主链路:创建短链与访问重定向。

  • Load Balancer:分发流量、健康检查、提升可用性。
  • API Servers:创建与重定向接口,做鉴权、限流、校验。
  • URL Generation Service:生成 key、处理自定义别名、过期与冲突检测。
  • Redirection Service:解析 short key、查 cache/DB,返回 301/302。
  • Database:持久化 short→long 映射与元数据。
  • Cache:热点映射快速命中。
  • Analytics(可选):异步记录与聚合点击。

533. 短链映射存储为什么常选 NoSQL(DynamoDB/Cassandra)?SQL 什么时候更合适?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: database, nosql, tradeoff)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c476 | 官方: 是 | 付费: 否

答案:

答案重定向的核心是用 short key 做海量KV(Key-Value)查找,适合可水平扩展的 NoSQL。

  • NoSQL 优点:分区/副本机制成熟、易扩展、高可用,适合亿级 key-value 访问。
  • SQL 适用:需要复杂关系与事务、多表关联、强一致计费或复杂报表。
    常见组合:NoSQL 做映射主存储,统计分析落到数据仓库(Data Warehouse)/OLAP(Online Analytical Processing)。

534. 短链 key 生成有哪些常见方案?Hash+Base62 和 自增ID+Base62 各自优缺点是什么?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: key-generation, base62, collision)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c479 | 官方: 是 | 付费: 否

答案:

答案短链 key 生成要满足:短、唯一、可扩展、碰撞可控。
Hash + Base62- 对长链做 MD5/SHA-256,取部分 bit 后 Base62 编码。

  • 优点:无中心 ID 服务;可做同 URL 去重。
  • 缺点:存在碰撞;同 URL 生成同 key;需碰撞处理(加盐/重哈希/扩 bit)。
  • 位 Base62 容量约 62^7 ≈ 3.5B(Billion)。
    ID + Base62- 分配自增或分布式唯一 ID,再 Base62 编码。
  • 优点:天然无碰撞、实现直观。
  • 缺点:可预测且可能被枚举;中心化 ID 可能成瓶颈。
  • 优化:Snowflake 分布式 ID + 混淆/加密后再编码。

535. 短链自定义别名(Custom Alias)需要做哪些校验与冲突处理?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: custom-alias, validation)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c47c | 官方: 是 | 付费: 否

答案:

答案自定义别名把 key 生成权交给用户,必须做严格校验。

  • 唯一性:写入前查库/条件写保证原子唯一。
  • 字符校验:限制可用字符与长度,避免不可用路径。
  • 保留词:拦截 admin/help/about 等内部路由。
  • 风控:敏感词/仿冒词/黑名单域名联动审核。
    冲突返回 409(Conflict),并可建议替代别名(Alias)。

536. 短链(Short Link)过期(Expiration)要怎么实现?为什么要同时做“后台清理 + 重定向(Redirect)实时校验”?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: expiration, http-410, ttl)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c47f | 官方: 是 | 付费: 否

答案:

答案过期要兼顾正确性(Correctness)与成本(Cost)。

  • 写入时保存 expiration_time(用户指定或默认)。
  • 重定向实时校验:过期返回 410 Gone。
  • 后台任务:定期标记/删除过期数据,控制存储与索引膨胀。
    两者缺一不可:只清理会有延迟窗口(Delay Window);只实时校验会让数据越积越多。缓存(Cache)TTL(Time-To-Live)也要不超过过期时间。

537. 短链重定向(Redirect)应该返回 301(Moved Permanently)还是 302(Found)?各自影响是什么?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: http, 301, 302)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c482 | 官方: 是 | 付费: 否

答案:

答案301 更偏“永久”,302 更偏“临时/可变”。

  • 301:更利于缓存与 SEO,性能好;但映射变化时可能被客户端缓存旧结果。
  • 302/307:适合活动链接、AB 测试、快速回滚,但缓存收益可能更少。
    实践:稳定短链用 301,可变跳转用 302/307 并配合 cache-control(缓存控制)。

538. 短链系统如何做分析统计(Analytics)而不拖慢重定向延迟(Latency)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: analytics, async, kafka)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c485 | 官方: 是 | 付费: 否

答案:

答案把统计从同步跳转链路里拆出去:重定向只做查找与返回,点击事件异步写入队列(Queue)/日志流(Log Stream)。

  • 点击事件进 Kafka/Kinesis 等。
  • 下游批/流处理聚合,落数据仓库或 OLAP。
  • 需要近实时计数可用 Redis counter,再周期回写。
    这样统计系统降级也不影响核心跳转。

539. 短链系统如何处理分片(Sharding)?Range 分片 vs Hash 分片怎么选,扩容时有哪些坑?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: sharding, consistent-hashing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddd9fe6ae93548e95c488 | 官方: 是 | 付费: 否

答案:

答案Range 分片实现简单但容易写热点(Write Hotspot);Hash 分片更均匀但扩容会涉及数据迁移(Data Migration)。

  • Range:按自增区间分片,易热点与倾斜。
  • Hash:按 hash(short_key)%N 分片更均匀;扩容需一致性哈希减少搬迁。
    短链 KV(Key-Value)场景通常更偏 Hash 分片或使用 DynamoDB/Cassandra 的内建分区(Partition)。

540. 短链系统的可用性(Availability)怎么保证?复制(Replication)、故障切换(Failover)、多地域部署(Multi-Region Deployment)分别解决什么问题?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: availability, replication, failover, multi-region)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddda1e6ae93548e95c65f | 官方: 是 | 付费: 否

答案:

答案- 复制(Replication):多副本防单点故障(Single Point of Failure)与数据丢失。

  • 故障切换:自动切主/切流量,降低 MTTR。
  • 多地域:就近访问降延迟,并抵御区域级故障。
    常见落地:多 AZ(Availability Zone)+ 健康检查(Health Check)+ 自动扩缩容(Auto Scaling);存储层多副本;跨 Region 复制按 RPO(Recovery Point Objective)/RTO(Recovery Time Objective)设计。

541. 短链系统(Short Link System)需要处理哪些边界情况(Edge Cases)?HTTP 404、410、以及冲突场景(Conflict Scenarios)该怎么返回?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: edge-cases, http-404, http-410, http-409)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddda1e6ae93548e95c662 | 官方: 是 | 付费: 否

答案:

答案- 不存在:404(Not Found)

  • 过期:410
  • 冲突(hash/custom alias):创建时 409
  • 非法输入:400;权限不足:403
    建议把 404/410/409 做指标监控(Metrics Monitoring),异常飙升可能是爬虫(Crawler)/攻击(Attack)或配置错误(Configuration Error)。

542. 短链系统的安全与反滥用(Security and Abuse Prevention)怎么做?限流(Rate Limiting)、输入校验(Input Validation)、HTTPS、监控告警(Monitoring and Alerting)分别覆盖什么风险(Risk)?

  • 知识点: 后端 / 数据库 / DevOps/云 / 安全 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, url-shortener, redis, nosql, api-design, scalability, security;标签: security, rate-limiting, monitoring, phishing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddda1e6ae93548e95c665 | 官方: 是 | 付费: 否

答案:

答案- 限流:防刷库(Database Flooding)与垃圾短链(Spam Short Link)。

  • 输入校验:URL 合法性、恶意域名/钓鱼检测。
  • HTTPS:防窃听与中间人攻击。
  • 监控告警:识别异常创建/异常点击、DDoS 与滥用。
    可选增强:验证码(CAPTCHA)、风险评分(Risk Scoring)、人工审核(Manual Review)与安全提示页(Security Warning Page)。

543. 在实时 Leaderboard(实时排行榜)里,玩家分数更新(write path,写路径)的典型流程是什么?为什么常用 WebSocket + 全局负载均衡(Global Load Balancer)+ 多数据中心(Multi-Data Center)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: write-path, websocket, global-lb, active-active, write-behind)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95edea | 官方: 是 | 付费: 否

答案:

答案分数更新链路(Update Pipeline)要同时满足低延迟(Low Latency)与跨地域可写(Cross-Region Writability)。典型流程如下:

  • 客户端与负载均衡器建立 WebSocket 连接,用于实时双向通信与状态推送。
  • 全局负载均衡(Global LB)把请求路由到距离最近的数据中心(就近接入降低 RTT)。
  • 应用服务在 Redis Sorted Set 上执行原子更新(如 ZINCRBY),保证排行榜实时可读。
  • 通过写后端(write-behind)模式异步把更新落到关系型数据库,提供持久化与复杂分析查询能力。
    多数据中心 + active-active(各 DC 都可写)能减少单区域故障影响(Single-Region Failure Impact),并把写入分摊到就近区域(Proximity-Based Routing);WebSocket 则让“分数变化(Score Change) → 排名变化(Ranking Change)”可以实时推送给在线玩家(Online Player)。

544. 什么是 write-behind cache(写后端缓存)?它在排行榜(Leaderboard)场景里解决了什么问题,有哪些风险需要兜底(Fallback Measures)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: write-behind, consistency, durability, idempotency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95eded | 官方: 是 | 付费: 否

答案:

答案Write-behind cache 指写请求先落到缓存(Cache,如 Redis),再由后台异步(Asynchronously)把数据写入持久化存储(Persistent Storage,如关系型数据库(Relational Database))。在排行榜里它的价值是:

  • 降低写延迟:玩家得分更新先写 Redis,排行榜立刻可读。
  • 提升吞吐:把高频写入从 DB 侧移走,DB 只承受批量/异步写。
  • 削峰填谷:写入队列化后可平滑流量。
    主要风险与兜底- 一致性延迟(Consistency Lag):DB 会短暂落后于缓存;需要明确读路径(Read Path)优先从缓存读取最新值。
  • 数据丢失:异步落盘前缓存故障可能导致丢写;可通过持久化(AOF/RDB)、多副本、以及将写事件投递到队列(Kafka)实现可重放。
  • 顺序与幂等:同一玩家多次更新要保证顺序/幂等,常用版本号、时间戳或幂等 key。

545. 为什么很多高并发 Leaderboard(高并发排行榜)会用 Serverless(无服务器计算)来做写后端(Write-Behind)/读穿透(Read-Through)逻辑?和 VM/容器(Virtual Machine/Container)相比的核心权衡(Key Trade-off)是什么?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: serverless, autoscaling, tradeoffs)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95edf0 | 官方: 是 | 付费: 否

答案:

答案把缓存编排(Cache Orchestration,即 write-behind / read-through)做成 Serverless 的主要动机是最小化运维(Minimal Operations)与自动扩缩容(Auto-Scaling):

  • 无需预置服务器,按需调用,自动扩到峰值。
  • 按执行时间计费,某些波峰波谷明显的流量形态下更经济。
  • 适合事件驱动:分数变更触发函数 → 写 DB / 推 CDN / 推消息队列。
    权衡点- 冷启动(Cold Start)与时延(Latency):函数可能慢于常驻服务(Long-Running Service),不适合每次都在关键链路(Critical Path)里执行重活。
  • 限制多:运行时、连接数、执行时长等限制可能影响复杂逻辑。
  • 成本结构:单位计算可能更贵,但可换来更高利用率与更低运维。
    实践上常见搭配:关键重定向(Critical Redirect)/高出网链路(High Egress Path)仍用 VM/容器做精细化 egress 控制(Egress Control);非关键的持久化(Persistence)、推送(Push)、聚合(Aggregation)用 Serverless 做事件处理(Event Handling)。

546. 排行榜读路径(read path)如何实现 read-through cache?缓存未命中时应该怎么做,如何避免 thundering herd?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: read-through, cache-miss, thundering-herd)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95edf6 | 官方: 是 | 付费: 否

答案:

答案Read-through cache 的核心是:读请求先查缓存,未命中由缓存层(或函数)负责回源 DB 并回填缓存。

  • 客户端通过 WebSocket/HTTP 请求查看排行榜。
  • 服务先从 Redis Sorted Set 读取(如 ZREVRANGE)。
  • 若缓存未命中或数据不完整,则回源关系型数据库(通常走读副本)查询。
  • 将结果写回缓存并设置合适的 TTL/更新策略,再返回给客户端。
    避免 thundering herd(惊群)- 请求合并/互斥锁:同一 key miss 时只允许一个请求回源。
  • 分层缓存:在 DB 前增加一层 cache(或反向代理缓存)缓冲热点。
  • 过期抖动:给 TTL 加 jitter,避免同时过期。
  • 预热:top10 等热点榜单定时预计算与预热。

547. Redis Sorted Set 在排行榜里怎么用?ZADD、ZREM、ZINCRBY 分别做什么,时间复杂度大概是多少?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: redis, sorted-set, commands, complexity)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95edfc | 官方: 是 | 付费: 否

答案:

答案Sorted Set 是“member + score”的有序集合,天然适合做实时排名:score 变化即排名变化。

  • ZADD key score member:新增/更新玩家分数(Upsert),时间复杂度通常 O(log n)。
  • ZREM key member:移除玩家,通常 O(log n)(批量移除会随 k 增长)。
  • ZINCRBY key increment member:对玩家分数做原子自增并返回新分数,通常 O(log n)。
    在实现上,Redis Sorted Set 结合了 hash 与 skiplist:hash 负责 member→score,skiplist 负责按 score 排序,因此大多数操作能维持对数级别性能。

548. 如何获取 Top N(如 Top 10)排行榜?为什么常用 ZREVRANGE + HMGET 批量取元数据?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: top-n, zrevrange, hmget, metadata)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95edff | 官方: 是 | 付费: 否

答案:

答案Top N 属于绝对榜单(absolute leaderboard)常见读法:

  • 用 ZREVRANGE leaderboard 0 N-1 从 Sorted Set 按分数从高到低取出前 N 个 member(玩家 ID)。
  • 玩家昵称、头像等元数据通常存 Redis Hash(或独立缓存)里,用 HMGET 一次性批量取回,避免 N 次网络往返。
    这样可以把“排名查询”和“展示信息查询”拆开,但仍保持极少的 round-trip,适合高并发下的低延迟读取。

549. 如何查询某个玩家的分数与排名?Z SCORE / ZREVRANK 的含义是什么,排名为什么是 0-based?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: player-rank, zscore, zrevrank, pagination)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee02 | 官方: 是 | 付费: 否

答案:

答案查询单个玩家通常分两步:

  • ZSCORE key member:返回该玩家在榜单中的分数,时间复杂度通常 O(1)。
  • ZREVRANK key member:返回该玩家在“从高到低”排序下的名次,时间复杂度通常 O(log n)。
    0-based 的意思是:最高分玩家 rank=0,第二名 rank=1。做分页或计算“上下邻居”时更方便(直接用 rank 做数组索引)。如果产品要展示 1-based 名次,输出时 +1 即可。

550. 如何实现相对榜单(查看某玩家上下各 N 名)?具体命令与边界处理怎么做?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: relative-leaderboard, range, edge-cases)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee06 | 官方: 是 | 付费: 否

答案:

答案相对榜单的核心是先拿到玩家的 rank,再取 rank 左右的区间。

  • 用 ZREVRANK key member 获取目标玩家 rank=r。
  • 计算区间:start = max(r - N, 0),stop = r + N。
  • 用 ZREVRANGE key start stop 拉取区间内玩家(按分数从高到低)。
    边界要处理:当玩家在榜首/榜尾时,start/stop 会越界;此外若玩家不存在,先返回 404 或业务错误码。为了展示信息完整,通常还会配合 HMGET 批量取元数据。

551. 排行榜如何处理分数并列(tie)?为什么可以用时间戳作为 tie-breaker?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: tie-breaker, timestamp, ranking)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee0a | 官方: 是 | 付费: 否

答案:

答案并列(tie)的本质是多个玩家分数相同,需要一个稳定的二级排序规则,避免排名“抖动”。常见做法:

  • 时间戳优先:分数相同则按更新时间较早者胜出(older timestamp wins),体现“先到先得”。
  • 实现方式:把时间戳存在 Redis Hash 或 DB;排序时通过 Lua 脚本、组合 score(如 score 的小数位编码时间)、或读出候选集合后在应用层二次排序。
    时间戳(timestamp)作为 tie-breaker 的优点是可解释、稳定,并且在竞争场景中具备直觉公平性。

552. 如何通过推送通知(push notifications)在排名变化时提醒玩家?为什么要用 change feed/trigger + 队列(queue)+ Bloom Filter(布隆过滤器)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: push, event-driven, queue, bloom-filter)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee0d | 官方: 是 | 付费: 否

答案:

答案推送链路应尽量与核心读写解耦,避免影响排行榜延迟:

  • 用数据库 trigger 或 change feed 捕获排名变化事件(或由业务层产出事件)。
  • 触发 Serverless 把事件写入消息队列(Kafka/SQS/RabbitMQ),实现异步处理与削峰。
  • 推送服务消费队列后发通知(APNs/FCM 等)。
    Bloom Filter(布隆过滤器)可用来防止同一玩家在短时间内收到重复通知(例如“只提醒一次被超越”):把已通知的 player_id 写入 Bloom Filter,后续事件先判断是否已通知。

553. 如何设计全局榜单(global leaderboard)与多场景榜单?ZUNIONSTORE 能解决什么问题?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: global-leaderboard, zunionstore, precompute)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee10 | 官方: 是 | 付费: 否

答案:

答案当存在多个游戏模式/场景时,通常会为每个场景维护一个 Sorted Set(有序集合)。全局榜单需要把各场景分数聚合:

  • 维护一个 global Sorted Set,表示跨场景的累计分数。
  • 使用 ZUNIONSTORE 对多个 Sorted Set 做并集聚合(可加权),产出一个新的集合用于全局展示。
    注意:并集计算本身有成本,通常会做异步预计算(例如每分钟/每 5 分钟更新一次),或只对热门榜单做增量更新。

554. 历史榜单(historical leaderboard)怎么做?为什么会用长 TTL 缓存、CDN(内容分发网络)、对象存储(object storage),以及 Redis Streams(Redis 流)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: historical, cdn, long-ttl, redis-streams)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee13 | 官方: 是 | 付费: 否

答案:

答案历史榜单的读多写少且可容忍一定延迟,适合“缓存优先 + 分层存储”。典型流程:

  • 客户端先通过 DNS 解析到最近数据中心。
  • 极热门历史榜单可直接命中 CDN(长 TTL)。
  • 请求到达 Web Server/函数后先查专用缓存(长 TTL)。
  • 缓存 miss 再查关系型数据库的只读副本。
  • 头像等静态资源放对象存储(S3 等)。
    Redis Streams(Redis 流)适合用来记录历史事件流(低内存开销、支持 range 查询与分页),例如按时间范围回看某场比赛的排行变更。

555. 如何实现日榜/周榜/月榜?为什么要为不同时间窗口创建不同 Sorted Set(有序集合),并把冷数据迁移到冷存储?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: time-window, daily-weekly-monthly, cold-storage)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee16 | 官方: 是 | 付费: 否

答案:

答案时间窗口榜单的关键是隔离数据:日榜只看当天,周榜只看本周。

  • 为每个窗口创建独立的 Sorted Set(例如 lb:daily:2026-01-19、lb:weekly:2026-W03)。
  • 写入时同时更新对应窗口的集合(或通过流处理异步聚合)。
  • 过期窗口的数据可迁移到冷存储(对象存储/数据湖),节省 Redis/热存储成本。
  • 热门筛选(如地区、好友圈)可预计算,降低实时计算压力。

556. 好友圈排行榜怎么做?ZINTERSTORE 的作用是什么,为什么也可以让客户端本地合并来减轻服务端压力?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: friends, zinterstore, personalization, client-side)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee19 | 官方: 是 | 付费: 否

答案:

答案好友圈榜单需要把“好友集合”与“全局榜单”取交集。

  • 将好友列表维护为一个 Sorted Set(初始 score=0)。
  • 用 ZINTERSTORE 对好友集合与全局榜单做交集,产出好友圈榜单。
    如果用户规模很大,服务端为每个用户实时生成好友榜单会很重。可选方案是客户端合并:客户端拿到好友列表与全局榜单的局部数据,在本地计算并缓存,从而把个性化计算“下沉”到端侧,按玩家规模线性扩展。

557. 当某个榜单特别热门导致单个 Redis 节点扛不住时,如何做缓存分片(sharding)?以 score 分片 vs 以 player_id 分片各有什么取舍?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: cache-sharding, score-shard, playerid-shard, scatter-gather)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee1c | 官方: 是 | 付费: 否

答案:

答案热门榜单会把 QPS(queries per second)与内存压力集中到单节点,需要分片(partitioning)。两种思路:
按 score 分片- 优点:取 Top10、取附近排名时更自然(按分数范围切片)。

  • 缺点:查询某个 player 的 rank/score 变复杂,因为 player 的位置不固定且需跨分片定位。
    按 player_id 分片- 优点:查单个玩家分数很简单(直接命中对应分片)。
  • 缺点:取 Top10 需要跨分片聚合(scatter-gather),会增加读复杂度。
    一个折中做法是维护两层缓存:玩家缓存(按 player_id 分片存分数)+ 榜单缓存(按 score 或按 key 分片存局部排行),查询 rank 时先从玩家缓存拿 score,再去榜单缓存定位排名。

558. Redis Cluster 的 hash slots(哈希槽)如何帮助自动分片?为什么 reshard/rehash(重新分片/重新哈希)会带来数据搬迁成本?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: redis-cluster, hash-slots, reshard)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee1f | 官方: 是 | 付费: 否

答案:

答案Redis Cluster 通过固定数量的 hash slots 把 key 映射到不同节点,实现自动分片。客户端根据 key 计算 slot 并路由到对应节点。

  • 新增/移除节点时,需要把部分 hash slots 重新分配(rebalance/reshard)。
  • slot 迁移意味着对应 key 的数据要在节点间搬迁与重写,会带来网络与 I/O 开销,期间可能出现延迟抖动。
    如果追求“连续 slot 分布”,数据搬迁会更多;若允许非连续分布,运维上更灵活但需要更成熟的运维与监控来控制迁移窗口。

559. 一致性哈希(consistent hashing)在排行榜分片里有什么优势?为什么会引入 scatter-gather(散集操作),且更新分数时可能需要“移除再插入”?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: consistent-hashing, scatter-gather, rebalancing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee22 | 官方: 是 | 付费: 否

答案:

答案一致性哈希的核心优势是:节点增减时只迁移少量 key,降低扩缩容的数据搬迁成本。
但在排行榜里,如果分片导致数据非连续分布,想要算全局 Top10 或某玩家全局 rank,就可能需要:

  • scatter-gather:并行查询所有分片的候选结果,再在服务端合并排序。
  • 更新时重定位:若分片规则与 score 相关,score 变化可能让记录属于另一个分片,需要从旧分片移除并插入新分片,保证数据落在正确 shard。
    因此一致性哈希更适合“按 key 分片”的 KV(key-value)场景;如果要做全局排序类查询,通常会额外做预计算或维护全局索引(global index)来减少 scatter-gather 成本。

560. 排行榜如何应对海量并发读写?为什么 Redis 单线程执行反而有利于原子更新(atomic update)?collapse forwarding(坍缩转发)是什么?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: concurrency, atomicity, collapse-forwarding, lua)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee27 | 官方: 是 | 付费: 否

答案:

答案海量并发下,重点是:读要抗爆、写要原子、缓存要分摊压力。

  • Redis 原子写:Redis 处理命令时是单线程顺序执行(网络 I/O 可多线程),因此像 ZINCRBY 这种更新天然串行化,便于保证原子性与一致性。
  • 读扩展:通过多层缓存、分片、CDN/客户端缓存减少回源。
  • collapse forwarding:在反向代理/缓存层把对同一资源的并发回源请求“合并”为一次回源,其余请求等待结果复用,减少 DB/后端被同一热点击穿。
    如果需要更复杂的差分更新或自定义原子逻辑,可以用 Lua(脚本语言)脚本,但要注意脚本执行会阻塞 Redis 主线程,需控制脚本复杂度与时长。

561. Redis Sorted Set(有序集合)的内部实现是什么?为什么说它结合了 hash(哈希)与 skiplist(跳跃表),从而让多数操作是 O(log n)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: data-structure, skiplist, hash, complexity)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb4e6ae93548e95ee2a | 官方: 是 | 付费: 否

答案:

答案Redis Sorted Set(有序集合) 内部通常用“双结构”实现:

  • Hash:维护 member → score 的映射,便于 O(1) 级别查分数。
  • Skiplist:按 score 有序存储,支持快速插入、删除与范围查询,平均复杂度接近 O(log n)。
    因此像更新/插入(需要在有序结构里定位)通常是 O(log n)(对数时间复杂度),而直接取分数(只走 hash(哈希))可以接近 O(1)(常数时间复杂度)。这也是 Sorted Set(有序集合) 适合做排行榜的核心原因之一。

562. 高可用设计里什么是“可降级服务(degradable service)”?为什么要区分关键/非关键服务并在高峰期节流(throttling)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: high-availability, degradation, rate-limit, circuit-breaker)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f007 | 官方: 是 | 付费: 否

答案:

答案可降级(degradable)指系统在压力过大或部分组件故障时,主动关闭/削弱非关键能力,优先保证核心功能可用。

  • 区分关键服务(例如更新分数、查询榜单)与非关键服务(例如复杂统计、个性化推荐、部分通知)。
  • 在峰值或故障时对非关键服务限流/节流,减少连锁故障。
  • 必要时直接熔断关闭非关键链路,保护整体延迟与可用性。
    这种策略本质是用“功能完整性”换“系统生存”,配合 autoscaling(自动伸缩) 与 error budget(错误预算) 能让服务在突发流量下更稳。

563. 排行榜如何优化低延迟?为什么多 AZ 部署(多可用区部署)、异步写 DB(异步写数据库)、客户端/CDN 缓存(客户端/内容分发网络缓存) 和分页都很关键?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: low-latency, multi-az, pagination, cdn)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f00a | 官方: 是 | 付费: 否

答案:

答案低延迟目标是让玩家“看到的排名变化”尽可能实时且稳定:

  • 多 AZ/就近部署:缩短网络距离,降低 RTT。
  • 异步写 DB:把持久化从关键链路移走,避免写放大延迟。
  • 客户端/CDN 缓存:对热门榜单与历史数据直接在边缘命中。
  • 分页:ZREVRANGE 在返回很大范围时可能变慢,分页能限制返回 m,稳定 O(log n + m)。
    此外可以预计算热门筛选条件,或在客户端做部分计算并缓存,进一步降低服务端压力。

564. 可靠性与可观测性怎么做?Prometheus/Grafana(普罗米修斯/格拉法纳)、checkpoint(检查点)、leader-follower(主从模式)、快照(snapshot) 分别解决什么问题?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: reliability, observability, prometheus, grafana, checkpoint)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f00d | 官方: 是 | 付费: 否

答案:

答案可靠性要回答“出事了能否快速发现 + 快速恢复 + 不丢关键数据”。

  • Prometheus + Grafana:采集时序指标(QPS、延迟、错误率、内存),可视化与告警。
  • Checkpoint(持久化):Redis 做 AOF/RDB 或定期落盘,防止内存故障导致数据全丢。
  • Leader-Follower:缓存/存储做主从复制与 failover,提高可用性。
  • 快照(snapshot):关系型数据库定期快照,支持灾难恢复与回滚。
    再配合限流(rate limiting)、熔断(circuit breaking) 与多层缓存,可以把局部故障隔离在可控范围内。

565. 最小运维成本(minimal operational overhead)通常怎么实现?哪些组件更适合托管化(managed)/Serverless(无服务器)?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: ops, managed-services, autoscaling, cost)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f011 | 官方: 是 | 付费: 否

答案:

答案最小运维成本的策略是:把“可标准化的能力”尽量交给云托管服务,把自研聚焦在业务逻辑上。

  • 用 Serverless 承担事件驱动任务:写后端持久化、缓存回填、通知触发、离线聚合。
  • 用托管服务:托管数据库、托管缓存、托管消息队列、托管监控告警。
  • 启用 Autoscaling:基于指标告警自动扩缩容,减少人工值守。
  • 统一监控与告警:让问题可见、可定位。
    前提是:关键链路仍需做容量规划与成本评估,避免“按需计费”在极端峰值下反而更贵。

566. 排行榜安全怎么做,防止恶意刷分或伪造更新?JWT(JSON Web Token)、加密传输、异常检测、shadow ban(影子封禁)、least privilege(最小权限) 分别起什么作用?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: security, jwt, anomaly-detection, least-privilege, shadow-ban)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f014 | 官方: 是 | 付费: 否

答案:

答案排行榜安全要解决“请求可信 + 行为可疑可识别 + 权限最小化”。

  • 加密传输:TLS 防抓包与中间人攻击,避免分数更新被篡改。
  • JWT 鉴权:确保请求来自合法账号/设备,并可携带权限声明。
  • 限流:限制更新频率,防刷接口与 DDoS。
  • 异常检测(telemetry):监控分数增长速度、地理位置跳变、设备指纹异常等,识别作弊。
  • Shadow ban:对作弊玩家“只对自己可见”,减少对正常用户的影响与对抗升级。
  • Least privilege:服务/账号只拿必要权限,降低被攻破后的损失面。

567. 为什么说小规模实时排行榜可以用关系型数据库(Relational Database),但互联网规模更适合 Redis Sorted Set(Redis 有序集合)?关键瓶颈是什么?

  • 知识点: 后端 / 数据库 / 安全 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, leaderboard, redis, cache, serverless, scalability, reliability, security, websocket;标签: tradeoff, redis-vs-sql, bottlenecks)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696ddfb6e6ae93548e95f01a | 官方: 是 | 付费: 否

答案:

答案关系型数据库(Relational Database)能做排行榜,但在互联网规模下会遇到明显瓶颈(Bottleneck):

  • 排名查询往往需要排序/聚合,成本高且随数据量增长明显变慢。
  • 高频写入会带来索引维护与锁竞争,影响吞吐与延迟。
  • 为保持实时性,缓存 TTL 很难设置,容易出现“要么过期导致抖动、要么不实时”的矛盾。
    Redis Sorted Set(Redis 有序集合)是内存结构(In-Memory Structure),更新与取 TopN/排名都具备更低延迟(Latency),且天然契合 leaderboard(排行榜)访问模式。因此常见架构(Architecture)是:Redis 负责实时读写,关系型数据库负责持久化(Persistence)与复杂分析(读副本/数据仓库)。

568. 什么是分布式 Job Scheduler(分布式任务调度器)?它解决什么问题,典型应用场景有哪些?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: definition, use-cases)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961742 | 官方: 是 | 付费: 否

答案:

答案分布式 Job Scheduler(分布式任务调度器)是一个在多台机器/多节点上统一管理、调度、分发与执行任务(Job)的系统。它把“什么时候跑、跑在哪里、跑失败怎么办、跑到哪一步了”这些问题平台化,避免每个业务重复造轮子。
常见场景包括:批处理(Batch Processing)与 ETL、报表生成、定时/周期任务(Cron)、工作流编排(Workflow Orchestration)(多步骤任务)、大规模异步任务执行(比如批量通知、索引构建)。在规模上它需要支持海量任务与高可用(High Availability),并在节点故障时自动重调度。

569. 一个可扩展的分布式 Job Scheduler(分布式任务调度器)的功能需求(Functional Requirements)与非功能需求(Non-Functional Requirements)通常怎么定义?重点是什么?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: requirements, semantics)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961746 | 官方: 是 | 付费: 否

答案:

答案功能需求通常包含:提交一次性/周期任务、取消任务、分发到多个 worker(工作节点)执行、查询任务状态(queued/running/completed/failed)、以及防止同一任务被并发重复执行(至少要做到“尽量一次”)。
非功能需求重点在:可扩展(百万级任务)、高可用(无单点,worker 挂了能重调度)、低延迟(到点尽快被调度与执行)、一致性(Consistency)(保证 at-most-once / at-least-once 语义并可解释)。面试里最容易加分的是把“一致性语义 + 去重/锁 + 失败恢复”说清楚。

570. 为什么分布式 Job Scheduler(分布式任务调度器)需要 Job Store(任务存储)?Job Table(任务表)、Job Execution Table(任务执行表)、Schedules Table(调度表)、Worker Table(工作节点表)分别存什么?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: job-store, schema)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961749 | 官方: 是 | 付费: 否

答案:

答案Job Store(任务存储)用于持久化(Persistence)系统状态,让调度与执行可以在重启/故障后恢复,并提供可查询的审计与监控视图。

  • Job Table:记录 Job 元数据(job_id、user_id、frequency、payload、execution_time、retry_count、status 等)。
  • Job Execution Table:记录每次执行尝试(execution_id、start/end、worker_id、status、error_message),用于重试与排障。
  • Schedules Table:维护 next_run_time/last_run_time;一次性任务 next_run_time=execution_time,周期任务每次执行后更新 next_run_time。
  • Worker Table:记录 worker 节点信息(ip、status、last_heartbeat、capacity、current_load),用于分配与健康管理。

571. Job Submission Service(任务提交服务)的职责是什么?提交任务时通常要做哪些校验与写入?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: submission, idempotency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e96174c | 官方: 是 | 付费: 否

答案:

答案Job Submission Service(任务提交服务)是对外入口,负责把用户请求规范化并落到 Job Store(任务存储)。

  • 校验:payload 大小/格式、频率与执行时间合法性、用户权限、重复提交策略(是否允许同 payload 合并)。
  • 写入:创建 Job 记录(status=pending)、创建/更新 Schedules 记录(next_run_time)、初始化 retry_count 等。
  • 返回:生成并返回唯一 job_id,便于后续查询与取消。
    为了防止同一 job 并发执行,提交阶段也可以生成幂等键(Idempotency Key)(例如 user_id + client_request_id),保证重复请求不会创建多个 job。

572. Scheduling Service(调度服务)如何选择到期任务并推入队列?为什么需要更新 Job 状态为 SCHEDULED(已调度)?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: scheduling, enqueue, state-machine)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e96174f | 官方: 是 | 付费: 否

答案:

答案Scheduling Service(调度服务)周期性(如每分钟)从 Schedules Table(调度表)扫描 next_run_time 到期的任务,然后把 job_id/payload 推入分布式队列(Distributed Queue)供执行侧消费。与此同时把 Job Table(任务表)的状态从 pending 更新为 SCHEDULED(或 queued),用于:

  • 避免重复入队(同一批扫描重跑时可据状态跳过)。
  • 对外可观测:用户能看到任务已进入调度/排队阶段。
  • 为取消/重试提供判断:取消时若已 scheduled,需要进一步处理队列中的消息或在执行侧做取消检查。

573. 为什么需要分布式 Job Queue(Kafka/RabbitMQ)?它在调度(Scheduling)与执行(Execution)之间起什么作用?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: queue, decoupling, backpressure)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961752 | 官方: 是 | 付费: 否

答案:

答案分布式队列(Distributed Queue)是调度与执行之间的缓冲层(Buffer Layer)与解耦层(Decoupling Layer):

  • 削峰填谷:调度瞬间产生 5 万条任务时,队列吸收峰值,worker 按能力消费。
  • 弹性扩缩容:新增 worker 只需加入消费组即可提高吞吐。
  • 可靠投递:支持 ack、重投、至少一次投递语义,配合幂等可做到可控一致性。
  • 隔离故障:执行侧短暂挂掉不会把调度侧拖垮。

574. Execution Service 的 Coordinator 和 Worker 分工是什么?如何做负载均衡(Load Balancing)与失败重分配(Failure Reassignment)?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: execution, coordinator, load-balancing, reschedule)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961756 | 官方: 是 | 付费: 否

答案:

答案Execution Service 往往包含一个协调层(Coordinator/Orchestrator)与多个 Worker:

  • Coordinator:从队列拉取/接收任务,按 worker 的 capacity/load 分配任务;维护 worker 心跳;检测 worker 故障并把其任务重新入队;做全局负载均衡策略(如最小负载优先)。
  • Worker:实际执行 job;在 Job Execution Table 写入 running→completed/failed;回写输出与错误信息。
    故障处理上,Coordinator 需要区分“未开始任务”(直接重新入队)与“执行中任务”(结合 checkpoint/幂等策略决定重试或从断点恢复)。

575. 如何保证同一个 Job 不会被多个 Worker 并发执行?常见手段有哪些(锁/租约/幂等等)?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: dedup, lock, lease, exactly-once)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961759 | 官方: 是 | 付费: 否

答案:

答案要防止并发重复执行,常见做法是把“领取任务”做成原子操作(Atomic Operation):

  • 数据库原子状态迁移:用条件更新 UPDATE Job SET status='running' WHERE job_id=? AND status IN ('scheduled','queued'),只有一个 worker 能成功。
  • 分布式锁/租约:用 Redis/etcd 的 lock + TTL(lease),避免死锁并支持 worker 挂掉后自动释放。
  • 队列语义:消费确认(ack)+ visibility timeout(类似 SQS)确保同一消息不会被多个消费者同时成功确认。
  • 幂等执行:即使发生至少一次投递,也能通过幂等 key/去重表确保副作用只发生一次。
    面试里建议同时说明:系统通常是 at-least-once + 幂等(Idempotency),追求严格 exactly-once 成本很高。

576. 这个系统的 API 设计应该包含哪些核心接口?每个接口需要返回哪些关键字段?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: api, state-machine)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961763 | 官方: 是 | 付费: 否

答案:

答案核心 API 一般包括:

  • 提交任务 POST /jobs:返回 job_id、status、next_run_time、可能还有幂等 key。
  • 查询状态 GET /jobs/{job_id}:返回 job 元数据 + 当前 status + 最近一次 execution 信息(start/end、error)。
  • 取消任务 DELETE /jobs/{job_id}:返回取消结果(canceled / already running / not found)。
  • 列出待执行 GET /jobs?status=pending&user_id=...:用于管理台/用户列表。
  • 按 worker 查询执行 GET /job/executions?worker_id=...:用于排障与容量分析。
    关键点是:每个接口要和 Job 状态机(State Machine)一致,并明确取消在不同状态下的语义。

577. 为什么在这个场景里 NoSQL(DynamoDB/Cassandra)可能比 SQL 更合适?有哪些前提条件?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: nosql, dynamodb, cassandra, tradeoffs)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961766 | 官方: 是 | 付费: 否

答案:

答案当系统每天写入百万级 Job且读写吞吐接近、数据结构相对固定、查询以主键/简单条件为主时,NoSQL 更容易水平扩展(Horizontal Scaling):

  • 天然分区与高吞吐,适合高并发写入与按 key 查询。
  • 高可用部署成熟(多副本、跨 AZ)。
  • 避免复杂 join,模型更贴近任务调度的 KV/宽表访问模式。
    前提是:你能接受弱事务(Weak Transactionality)(不强依赖 ACID)、尽量减少跨表 join,并把复杂分析留给异步管道或数据仓库。

578. 如何扩展 Scheduling Service?为什么要按 next_run_time 分区/索引?当某一分钟有 50,000 个任务时会发生什么?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: scheduler-scaling, partitioning, hot-minute)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961769 | 官方: 是 | 付费: 否

答案:

答案Scheduling Service 的瓶颈通常在“每分钟扫描到期任务并入队”。按 next_run_time 分区/索引能让查询变成“定位到某一分钟的分区/索引段”,避免全表扫描。
如果某一分钟有 50,000 个任务(task),而调度(scheduling)只有单节点(single node):查询(query)+入队(enqueue)会拉长,导致任务启动延迟(startup latency);同时单点故障(single point of failure)会让这一分钟的任务全部卡住。解决思路是并行调度(parallel scheduling):把扫描(scanning)与入队(enqueueing)拆到多个调度 worker(scheduler worker)上,并通过分段/锁(segmentation/locking)来避免重复处理(duplicate processing)。

579. 什么是 segment 分段调度?Coordinator 如何分配 segment 以避免多个调度 worker(scheduler worker)重复处理同一批任务?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: segmentation, coordinator, rebalance)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e96176c | 官方: 是 | 付费: 否

答案:

答案Segment 的核心是把 Schedules 表里的任务按一个额外维度逻辑分片(logical sharding)(segment=1,2,3...),让每个调度 worker(scheduler worker)只负责自己的分片集合(shard set),从而避免重复扫描同一批任务。

  • Coordinator 维护“worker → segments”映射。
  • worker 查询时带上 segment 条件:WHERE next_run_time=... AND segment IN (...)。
  • 当 worker 故障/扩容/流量波动时,Coordinator 重新分配 segments,实现动态再均衡。
    segment 的生成可用 hash(job_id) % N 或基于用户/租户分片(tenant sharding),关键是保证分布均匀并易于再平衡(rebalancing)。

580. Job 失败时如何重试?为什么要用指数退避(exponential backoff),以及如何处理 max_retries?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: retry, backoff, max-retries, jitter)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e96176f | 官方: 是 | 付费: 否

答案:

答案失败重试(retry)通常遵循“可控重试”原则:

  • worker 失败后先在 Job Table 增加 retry_count 并记录 execution 失败原因。
  • 若 retry_count < max_retries,则把任务重新入队或更新 next_run_time 为“延迟后再跑”。
  • 达到 max_retries 后将 job 标记为 failed,避免无限重试。
    指数退避(exponential backoff)用于应对瞬时故障(transient failure)(网络抖动、下游限流):立刻重试往往只会扩大拥塞;backoff(1min→5min→10min…)能给系统恢复窗口并降低雪崩风险(avalanche risk)。可叠加 jitter(随机抖动),避免大量任务同一时刻再次重试。

581. Worker 节点故障如何检测与恢复?Pending vs In-progress 任务分别怎么处理,checkpointing(检查点)有什么用?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: worker-failure, heartbeat, health-check, checkpointing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961772 | 官方: 是 | 付费: 否

答案:

答案故障检测(failure detection)常用两类机制:

  • Heartbeat:worker 周期性上报心跳,Coordinator 连续多次未收到则判定 unhealthy。
  • Health checks:Coordinator 主动探测 CPU/内存/磁盘/网络等,识别过载或失联。
    恢复(recovery)时要区分:
  • Pending(未开始):直接重新入队,交给其他 worker 领取。
  • In-progress(执行中):可能已产生部分副作用。可用checkpointing让长任务周期性写入进度到持久化存储,接管的 worker 从最后 checkpoint 继续;否则通常标记失败并重新入队重试,配合幂等来兜底。

582. Coordinator 是单点怎么办?如何用 leader election(领导者选举)(Raft/Paxos)+ etcd/ZooKeeper 做高可用(high availability)?共享状态放哪里?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: leader-election, raft, paxos, etcd, zookeeper, ha)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961775 | 官方: 是 | 付费: 否

答案:

答案Coordinator 既负责分配/再均衡(assignment/rebalancing),又负责健康监控(health monitoring),天然容易成为单点(single point of failure)。常见 HA 方案:

  • 部署多个 coordinator,使用leader election(Raft/Paxos)选出一个 active leader,其余 standby。
  • leader 挂了,其他节点检测到租约/心跳失效后快速重新选主并接管。
  • 选主与租约管理可用 etcd 或 ZooKeeper(它们内部实现一致性协议)。
    共享状态(shared state)(jobs/worker health/segment 分配)应存放在共享的分布式存储(distributed storage)(Job Store/元数据存储),而不是 leader 本地内存,这样新 leader 才能无缝接管。

583. 为什么要做提交层 Rate Limiting(限流)?如何设计每客户端 1000 次/分钟的限流,并处理超限的返回?

  • 知识点: 后端 / 数据库 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: rate-limiting, submission, 429)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e961778 | 官方: 是 | 付费: 否

答案:

答案提交层限流(rate limiting)用于防止单个客户端把系统打爆(调度、队列、存储都会受影响)。实现方式:

  • 按 client_id/user_id 做令牌桶或滑动窗口计数(Redis/边缘网关都可做)。
  • 限制 1000 次/分钟:窗口内超过阈值则拒绝。
  • 返回 429 Too Many Requests,并附带 Retry-After 或剩余配额信息,方便客户端退避重试。
    面试加分点:限流规则要与幂等键(idempotency key)配合,避免客户端重试(retry)导致重复创建 job。

584. 为什么还要在 Worker 层做并发限制(Concurrency Limit)?最大并发数(Max Concurrency)应该如何与资源容量(CPU/内存/下游)绑定?

  • 知识点: 后端 / 数据库 / 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, distributed-systems, job-scheduler, queue, kafka, rabbitmq, dynamodb, cassandra, leader-election, raft, etcd, zookeeper, retry, rate-limiting, checkpointing;标签: worker, concurrency, backpressure)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de11ae6ae93548e96177b | 官方: 是 | 付费: 否

答案:

答案即使队列里任务很多,也不能让 worker 无限并发(Unbounded Concurrency),否则会把 CPU/内存打满或把下游(DB/API)压垮。Worker 层并发限制(Worker-Level Concurrency Limiting)的做法:

  • 每个 worker 设置 max_concurrency(线程池/协程池/进程池)。
  • 根据 CPU 核数、内存占用、任务类型(I/O vs CPU)以及下游配额动态调整。
  • 结合自适应负载:当检测到资源逼近阈值(例如 CPU>80%)时降低并发或暂停拉取新任务。
    对外表现是系统整体吞吐(Throughput)更稳定,尾延迟(Tail Latency)更可控。

585. 什么是通知系统(Notification Service)?它在业务里通常负责哪些事情?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: intro, use-cases)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de21fe6ae93548e963b94 | 官方: 是 | 付费: 否

答案:

答案通知系统(Notification Service)用于在合适的时间把“重要信息”送达用户,支持邮件(Email)、短信(SMS)、Push、站内信(In-app Message)等多渠道(Channel)。它通常接收业务系统触发的通知请求(如下单成功、支付完成、发货、改密、告警),完成鉴权(Authentication)与校验、用户偏好(User Preference)与合规检查(Compliance Check)、消息模板渲染(Template Rendering)、排队与调度(Queuing and Scheduling)、分渠道投递(Channel Delivery)、失败重试(Retry)、投递结果回写与审计(Audit),并提供监控(Monitoring)与报表。

586. 设计通知系统(Notification System)时,功能性需求(Functional Requirements)和非功能性需求(Non-Functional Requirements)分别要覆盖哪些核心点?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: requirements)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de221e6ae93548e963d6e | 官方: 是 | 付费: 否

答案:

答案功能性需求(Functional Requirements)- 多渠道(Multi-Channel):Email / SMS / Push / In-app。

  • 多类型:交易类、营销类、系统告警等。
  • 定时发送:支持未来某一时间投递。
  • 频控/限流:尤其营销消息防骚扰。
  • 失败重试:对第三方通道失败做重试与降级。
    非功能性需求(Non-Functional Requirements)- 可扩展(Scalability):高峰可达百万级/分钟。
  • 高可用:组件故障不影响整体投递。
  • 可靠性:至少一次投递;部分场景追求“准一次/一次”。
  • 低延迟:关键通知尽快送达。

587. 根据“50M 日活、每人 5 条/天、峰值 1 分钟 100 万条”的假设,如何做规模估算(Capacity Estimation)与存储估算(Storage Estimation)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: capacity, throughput, storage)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de221e6ae93548e963d71 | 官方: 是 | 付费: 否

答案:

答案规模估算(Capacity Estimation)用于指导队列分区(Queue Partitioning)、消费者并发(Consumer Concurrency)、数据库分片(Database Sharding)与限流策略(Rate Limiting)。

  • 日通知量:50,000,000 × 5 = 250,000,000 条/天。
  • 峰值吞吐:1,000,000 / 60 ≈ 16,666(约 17k)条/秒。
    存储估算(Storage Estimation)若平均通知与用户数据 1KB:
  • 用户偏好等用户数据:50,000,000 × 1KB ≈ 50GB。
  • 通知日志/内容:50,000,000 × 5 × 1KB ≈ 250GB/天(不含索引与副本)。
    因此需要:可水平扩展的队列(Horizontally Scalable Queue)与消费者(Consumer)、日志按时间分区(Time-Based Partitioning)、冷热分层(Hot/Warm/Cold Tiering)与归档策略(Archival Policy)。

588. 通知系统(Notification System)的高层架构(High-Level Architecture)通常包含哪些组件?它们各自的职责是什么?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: architecture, components)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de224e6ae93548e963f49 | 官方: 是 | 付费: 否

答案:

答案- Notification Service:入口层(Ingress),鉴权校验(Authentication and Validation)、生成消息(Message Generation)、决定投递渠道,并写入队列;需要定时则对接 Scheduler(调度器)。

  • User Preference Service:用户偏好/退订/免打扰/频控规则,负责合规与防骚扰。
  • Scheduler Service:管理定时通知,到点后把任务投递到队列。
  • Notification Queue:解耦削峰(Kafka/RabbitMQ/SQS),按渠道或类型拆 topic。
  • Channel Processors:各渠道消费与投递(Email/SMS/Push/In-app),自带重试与错误处理。
  • Storage:用户偏好、定时任务、投递日志、内容/附件(RDB/NoSQL/对象存储)。

589. 为什么通知系统(Notification System)需要消息队列(Message Queue)?Kafka/RabbitMQ/SQS 这种队列在这里分别起什么作用?

  • 知识点: 后端 / 数据库 / 安全 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: queue, kafka, rabbitmq, sqs)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de224e6ae93548e963f4e | 官方: 是 | 付费: 否

答案:

答案队列的核心价值是解耦(Decoupling) + 削峰(Peak Shaving) + 重试(Retry):入口服务只负责把消息可靠写入队列,投递由消费者(Consumer)异步完成,避免峰值把通道或数据库打爆。

  • Kafka:高吞吐、可分区扩展,适合大规模事件流与日志型通知。
  • RabbitMQ:路由能力强、延迟低,适合复杂路由/确认机制场景。
  • SQS:托管化、运维成本低,配合 DLQ 做失败隔离。

590. 如何把一次通知请求拆成多渠道消息(fan-out),并保证每个渠道能独立扩缩容(scaling)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: fanout, topics, scaling)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de224e6ae93548e963f51 | 官方: 是 | 付费: 否

答案:

答案入口层把“通知请求”转成多个channel-specific message:每个渠道一条消息,写入对应topic(如email-topic / sms-topic / push-topic)。

  • 每个 Channel Processor 只消费自己的 topic,做到独立扩容与限流。
  • 消息体包含 requestId/messageId、渠道、收件人、渲染后的内容、优先级、重试次数等。
  • 渠道之间互不阻塞:短信拥塞不影响邮件与 push。

591. 用户偏好服务(User Preference Service)需要存哪些数据?如何实现退订(unsubscribe)、免打扰(do-not-disturb)和营销频控(frequency capping)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: preferences, dnd, rate-limit)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de224e6ae93548e963f54 | 官方: 是 | 付费: 否

答案:

答案- 渠道偏好(channel preference):不同通知类型对应允许的渠道组合。

  • 退订/Opt-out:按渠道或按类型的禁用开关,满足合规。
  • 免打扰:时间窗口 + 时区,关键告警可设置例外。
  • 频控:营销类每日/每小时上限,记录 sentToday 计数(可用 Redis 计数 + 过期)。
    入口服务(ingress service)在写入队列前先查询偏好并做裁剪与拦截,避免“发出去再后悔”。

592. 通知系统如何实现“定时发送”?Scheduler Service 的数据建模(data modeling)与查询方式是什么?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: scheduler, time-partition, idempotency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de224e6ae93548e963f57 | 官方: 是 | 付费: 否

答案:

答案定时发送的关键是:按时间高效取出“即将到期”的任务。

  • 把 scheduled notifications 存在按 scheduled_time 分区/排序的存储(如 NoSQL + time partition)。
  • Scheduler 以固定周期(每分钟或更细)扫描未来 1–5 分钟窗口的记录。
  • 到点后把消息投递到队列,并更新状态(scheduled → queued/sent)。
    要注意幂等(idempotency):同一条定时任务被重复触发时,依靠messageId/requestId做去重(deduplication)。

593. 通知服务入口层需要做哪些校验与安全控制?(鉴权(authentication)、参数校验(parameter validation)、内容审核(content moderation)等)

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: security, validation, auth)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de226e6ae93548e96412b | 官方: 是 | 付费: 否

答案:

答案- 鉴权(authentication):OAuth2/JWT/mTLS,区分内部系统与外部客户。

  • 参数校验:recipient、channels、type、模板参数、附件 URL 等。
  • 合规校验:用户 opt-out/DND/频控。
  • 内容与链接安全:可选敏感词、钓鱼链接检测、黑名单域名。
  • 入口限流:按 clientId/tenant 做 rate limit,防 DoS 与误调用。

594. 通道处理器(Channel Processor,Email/SMS/Push/In-app)如何设计重试(retry)?为什么要指数退避(exponential backoff)+ DLQ(死信队列,Dead Letter Queue)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: retries, backoff, dlq)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de228e6ae93548e96430a | 官方: 是 | 付费: 否

答案:

答案通道失败通常是暂时性(限流(rate limiting)、抖动(jitter)、供应商短故障),直接频繁重试会加重拥塞。

  • 指数退避:重试间隔逐步拉长(如 1m、5m、10m),并加 jitter 防同步风暴。
  • 最大重试次数:超过阈值后不再阻塞主流程。
  • DLQ:把“多次失败”的消息隔离出来,方便人工排查/回放。
    同时要区分可重试错误(retryable error,5xx、timeout)与不可重试错误(non-retryable error,邮箱格式错误、无效token)。

595. 通知日志(delivery logs)应该记录什么?怎么做可观测性(observability)指标与告警(alerting)?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: observability, logging, metrics)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de228e6ae93548e964310 | 官方: 是 | 付费: 否

答案:

答案日志既是审计(audit)也是排障依据。

  • 关键字段:requestId/messageId、userId、channel、provider、状态(queued/sent/failed)、错误码、重试次数、耗时、时间戳。
  • 链路追踪:入口到队列到处理器的 traceId。
    指标与告警- 吞吐(throughput):每渠道QPS(Queries Per Second)。
  • 成功率/失败率:按 provider、按错误码分桶。
  • 延迟:p50/p95/p99(端到端 + 通道侧)。
  • 队列积压:lag、消费者滞后。
    告警:失败率突增、延迟飙升、队列积压持续增长、DLQ(Dead Letter Queue)增量异常。

596. 如何做水平扩展(horizontal scaling)?Notification Service、队列、Channel Processors 各自怎么扩?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: scaling, partitions, consumers)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de228e6ae93548e964313 | 官方: 是 | 付费: 否

答案:

答案- Notification Service:无状态化(stateless) + LB(Load Balancer)扩实例;热点校验(偏好/频控)用缓存减少 DB(Database)。

  • Queue:Kafka 通过增加 partition 提升吞吐;RabbitMQ 通过集群/分片;SQS 天然扩展。
  • Channel Processors:按 topic 增加 consumer group 实例,结合 provider 限流做并发上限。
    关键:分区键(partition key)设计(如 userId、messageId)保证负载均匀且有序需求可控。

597. 用户数据与通知日志如何分片(sharding)/分区(partitioning)?为什么常用“按用户分片 + 按时间分区”?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: sharding, partitioning, retention)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de22be6ae93548e9644f9 | 官方: 是 | 付费: 否

答案:

答案- 用户偏好:按 userId 或地域做 sharding,便于就近读与均衡负载。

  • 通知日志:按时间(天/月)分区,常见查询是“最近 N 天”;也便于归档与删除。
    组合策略能同时解决:在线查询性能、写入吞吐(throughput)、以及历史数据成本控制。

598. 通知系统如何保证高可用(high availability)与可靠性?多 AZ(Availability Zone)复制、负载均衡、存储复制分别覆盖哪些故障?

  • 知识点: 后端 / 数据库 / 安全 / 系统设计/架构 / UI/UX 设计 (主题: system-design, notification-service, kafka, rabbitmq, sqs, redis, email, sms, push, dlq, observability, security;标签: ha, reliability, replication)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de22be6ae93548e9644fc | 官方: 是 | 付费: 否

答案:

答案- 多 AZ 部署:抵御机房级故障,入口与消费者跨 AZ。

  • 负载均衡:实例故障自动摘除,流量平滑切换。
  • 存储复制:偏好与日志多副本,避免数据丢失;跨 Region 做灾备。
    队列也要高可用配置(Kafka ISR(In-Sync Replicas)、副本;SQS(Simple Queue Service)多 AZ)。核心链路优先保证“写入队列成功”,后续投递可异步补偿。

599. 分布式计数器(distributed counter)的 API 通常怎么设计?如何获取计数值?

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: rest, websocket, sse;标签: API)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de486e6ae93548e9675df | 官方: 是 | 付费: 否

答案:

答案常见做法是提供 REST API 读取计数值,例如 GET /:webpage-id/counter,返回 count 与 updated_at,并设置 no-store 或短缓存(cache)策略避免读到过旧值。若要实时体验,客户端通常在页面加载后再建立 WebSocket/SSE(Server-Sent Events)连接,用流式消息持续更新 UI(User Interface),而 REST(Representational State Transfer)只承担首次加载或兜底查询。

600. 如何更新分布式计数器?为什么常用 PUT 而不是 POST?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: rest, idempotency;标签: PUT, idempotency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de486e6ae93548e9675e2 | 官方: 是 | 付费: 否

答案:

答案更新接口通常设计为 PUT /:webpage-id/counter,携带 action=increment/decrement。使用 PUT 的核心理由是强调幂等(idempotency)语义:在网络重试、超时或客户端重复提交时,系统更容易用请求去重键(如 userId+pageId+sessionId+timeWindow)把“同一进入/退出事件”变成一次性生效,避免重复加减导致计数漂移。

601. 客户端-服务器架构(client-server architecture)的常见挑战是什么?如何缓解“单点故障(SPOF,Single Point of Failure)”和“性能瓶颈”?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, reliability, scalability;标签: reliability, scalability, client-server)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de87a623565038f409cc9 | 官方: 是 | 付费: 否

答案:

答案常见挑战包括:服务器可能成为单点故障(SPOF)、高并发下性能瓶颈、以及系统规模扩大后的架构复杂度上升。
缓解 SPOF(Single Point of Failure)的常用手段是冗余(Redundancy)与故障转移(Failover):多实例部署、健康检查(Health Check)、自动切换,以及数据库/缓存的主从或多活复制。
缓解性能瓶颈(Performance Bottleneck)通常结合负载均衡(Load Balancing)与优化:在入口加 LB(Load Balancer),热点数据用缓存/CDN(Content Delivery Network),服务做水平扩容(Horizontal Scaling),并通过监控指标持续定位慢点。

602. 什么是微服务架构(Microservices Architecture)?它与单体架构(Monolithic Architecture)的核心区别是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, architecture;标签: microservices, monolith)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9ab623565038f40d6c0 | 官方: 是 | 付费: 否

答案:

答案微服务架构(Microservices Architecture)把一个大型应用拆分成多个松耦合、可独立开发/部署/扩缩容的服务,每个服务聚焦一个清晰的业务能力(接近“单一职责”)。与单体相比:单体把功能打包在一个进程/发布单元里,发布与扩容往往“全量一起动”;微服务则按服务边界独立演进,通过 API(Application Programming Interface)/事件协作,换来更好的团队自治与故障隔离(Fault Isolation),但也带来分布式复杂度(治理、观测、网络、数据一致性等)。

603. 如何开始做微服务拆分?什么是“按业务能力(Business Capability)拆分”?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, ddd;标签: decomposition, business capability)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9ab623565038f40d6c6 | 官方: 是 | 付费: 否

答案:

答案常见起步方式是按业务能力(Business Capability)拆分:先画出业务全景,把“业务提供给用户的价值模块”列出来(如商品目录、库存、订单、配送、用户、推荐、评价),再为每个能力建立对应服务。关键是边界要清晰:数据与规则尽量在服务内闭环,跨服务通过 API(Application Programming Interface)/事件交互。拆分不是一次到位,建议从高变更/高负载/高耦合的模块先下手,逐步演进。

604. 微服务的主要收益有哪些?哪些场景更适合微服务?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices;标签: benefits, tradeoffs)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9ad623565038f40d8b1 | 官方: 是 | 付费: 否

答案:

答案核心收益包括:独立部署与扩缩容(热服务单独加机器)、故障隔离(Fault Isolation)(单个服务出错不一定拖垮全局)、团队自治(小团队端到端负责)、以及技术栈多样性(不同服务可用最适合的语言/数据库)。更适合:业务复杂、团队规模较大、迭代频繁、需要对不同模块做差异化扩缩容与发布的系统。小团队/低复杂度项目往往用单体更划算。

605. 为什么微服务要避免“服务2直接读服务1的数据库”?正确做法是什么?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: microservices, api;标签: database per service, contracts)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9ad623565038f40d8b4 | 官方: 是 | 付费: 否

答案:

答案直接读别人的库会把数据库 schema(模式)变成隐式契约(Implicit Contract):一旦服务1改表,服务2就可能被悄悄打爆,而且很难追踪谁依赖了哪些字段,导致服务无法独立演进。正确做法是通过服务1提供的 API(Application Programming Interface)/事件获取数据:服务1对外暴露稳定契约(Contract),内部实现与数据结构可自由调整;需要读模型可用事件同步/物化视图(Materialized View)等方式构建。

606. 微服务之间通信协议怎么选?为什么要避免过于“脆”的协议(例如强绑定某语言运行时)?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, api, grpc;标签: protocols, backward compatibility)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daa0 | 官方: 是 | 付费: 否

答案:

答案通信协议要在性能、可演进性、跨语言性、可观测性(Observability)之间平衡。REST(Representational State Transfer)/JSON(JavaScript Object Notation)易用、生态广;gRPC(Google Remote Procedure Call)/Protobuf(Protocol Buffers)更高效且有强类型;事件/消息适合解耦与异步。避免强绑定某运行时的协议(如强依赖 JVM(Java Virtual Machine)的远程调用)是因为它会限制消费者技术栈,且兼容性/升级更难,长期会把系统锁死在某种实现细节里。

607. 什么是“Consumer Driven Contracts(CDC)”?它在微服务发布里解决什么问题?

  • 知识点: 后端 / 测试 / 系统设计/架构 / UI/UX 设计 (主题: microservices, testing;标签: CDC, release safety)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daa3 | 官方: 是 | 付费: 否

答案:

答案CDC(Consumer Driven Contracts)是由消费者定义契约(Contract):每个依赖方把自己对提供方 API(Application Programming Interface)的期望(请求/响应字段、语义、错误码等)写成可自动化验证的契约,并共享给提供方。提供方在发布前跑所有契约测试,确保改动不会破坏现有消费者,从而降低联调成本与回归风险,支持更安全的独立发布。

608. 微服务 API(Application Programming Interface)变更在生产环境如何做?“版本化 API”与“同服务新增 endpoint”各有什么取舍?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, api;标签: api evolution, versioning)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daa6 | 官方: 是 | 付费: 否

答案:

答案常见两种策略:版本化(v1/v2 并行,消费者逐步迁移)优点是迁移路径清晰;缺点是长期维护多版本成本高,修 bug 可能要双写。另一种是同服务新增 endpoint(保留旧接口,新需求走新接口,迁移完成后删除旧接口)优点是维持“单版本”运维更简单;缺点是需要更谨慎的兼容设计与迁移监控。实践中常配合 CDC(Consumer Driven Contracts)、灰度与观测指标。

609. “多微服务(Microservices)同一台操作系统(Operating System)/主机(Host)” vs “一服务一主机(Host)/容器(Container)”如何选择?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: microservices, docker, kubernetes;标签: deployment, isolation)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daaa | 官方: 是 | 付费: 否

答案:

答案多服务同主机的优点是资源利用率高、主机运维更少;但缺点是隔离性差、依赖冲突(例如同机 Java 版本)、以及扩容不够灵活。更推荐“一服务一隔离单元”(VM(Virtual Machine)/容器(Container)/Pod):服务更独立,便于弹性扩缩容与故障隔离。容器(Container)相较传统 VM(Virtual Machine)更轻量,适合微服务(Microservices)高密度部署。

610. 为什么微服务(Microservices)常需要 API Gateway(API 网关)?它通常承担哪些职责?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, api;标签: api gateway, edge)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40daae | 官方: 是 | 付费: 否

答案:

答案API Gateway(API 网关)提供统一入口,减少客户端直接面对大量服务的复杂度。它常承担:鉴权/授权、SSL(Secure Sockets Layer)终止、限流、路由与聚合、协议转换、缓存、日志与监控、以及部分安全策略。注意不要把过多业务逻辑塞进网关,否则会变成新的“巨石单体”。

611. 什么是 Service Discovery(服务发现)?为什么微服务(Microservices)更需要它?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, service-discovery;标签: service discovery, registry)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40dab1 | 官方: 是 | 付费: 否

答案:

答案Service Discovery(服务发现)用于在服务实例动态变化(扩容、故障、滚动发布)时,仍能让调用方找到正确的host:port。微服务(Microservices)实例数量多且变动频繁,硬编码地址会快速失效。常见做法是注册中心(如 Consul/etcd/ZooKeeper 等)+ 客户端/代理发现,并与负载均衡(Load Balancing)配合实现稳定路由。

612. 为什么要保持消息总线(Message Bus)/中间件(Middleware)“足够 dumb”?把业务逻辑塞进总线有什么风险?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, messaging;标签: message bus, event-driven)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40dab4 | 官方: 是 | 付费: 否

答案:

答案消息总线(Message Bus)的价值在于解耦与路由。一旦把业务规则塞进总线,它就会逐渐“懂业务”,形成新的中心化耦合点:变更需要跨团队协调、发布风险集中、测试边界模糊,还可能导致性能与可用性瓶颈。更推荐让总线专注传输与路由,业务逻辑放在服务侧;需要解耦时用事件驱动架构(Event-Driven Architecture)更自然。

613. 微服务(Microservices)常见的可靠性挑战是什么?Bulkhead(舱壁模式)与 Circuit Breaker(断路器模式)分别解决什么问题?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, reliability;标签: bulkhead, circuit breaker)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40dab7 | 官方: 是 | 付费: 否

答案:

答案微服务(Microservices)不是天然可靠:依赖链条长,网络超时、下游抖动、级联失败很常见。Bulkhead(舱壁模式)把资源分舱(线程池/连接池/实例组隔离),某一舱故障不拖垮其他舱;Circuit Breaker(断路器模式)在失败率超阈值时快速熔断,避免持续重试把下游打穿,并在冷却后半开探测恢复。两者配合超时、限流、重试退避可显著提升韧性。

614. 微服务(Microservices)的监控与告警怎么做?为什么健康检查(Health Check API)很关键?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: microservices, observability;标签: monitoring, health checks)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b0623565038f40dabd | 官方: 是 | 付费: 否

答案:

答案监控通常包含:指标(CPU/内存/延迟/错误率/饱和度)、日志、链路追踪三件套,并设置 SLO(Service Level Objective)/告警阈值。健康检查(Health Check API)接口让负载均衡器(Load Balancer)/监控系统能周期性判断实例是否可用:当实例不可用时可自动摘除、触发扩容或告警。它还能帮助区分“服务自身健康”与“下游依赖异常”,提升故障定位效率。

615. 微服务(Microservices)架构的主要代价/挑战有哪些?如何判断是否值得上微服务(Microservices)?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, architecture;标签: tradeoffs, when to use)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696de9b4623565038f40dea0 | 官方: 是 | 付费: 否

答案:

答案主要代价包括:分布式通信带来的延迟与失败处理、数据一致性与跨服务事务困难、服务治理(注册发现、配置、网关、限流)、可观测性与调试难度、以及运维与平台成本(CI/CD(持续集成/持续部署)、容器编排)。判断是否值得:看团队规模与组织结构、系统复杂度、发布频率、模块是否存在明显的独立扩缩容需求,以及是否具备平台与工程化能力。否则先用单体/模块化单体更稳。

616. 什么是微服务(Microservices)架构?它和单体架构(Monolithic Architecture)的核心区别是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, architecture, api)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb63623565038f4130c3 | 官方: 是 | 付费: 否

答案:

答案微服务(Microservices)架构把一个复杂系统拆分为一组小而自治的服务,每个服务围绕单一业务能力/职责构建,独立开发、部署与扩缩容,通过轻量 API(HTTP/gRPC、消息)协作完成整体业务。
与单体架构(Monolithic Architecture)相比,单体通常是一个可执行体/部署单元(Deployment Unit),模块间强耦合(Tight Coupling)、发布节奏绑定;微服务(Microservices)强调边界清晰、团队自治和独立交付,但会引入分布式系统(Distributed System)复杂度(网络、数据一致性、观测与治理)。

  • 单体:部署简单、事务一致性容易,但扩展与迭代容易被“整体”拖慢。
  • 微服务:可独立伸缩与故障隔离更好,但需要治理(网关、服务发现、链路追踪等)。

617. 微服务架构(Microservices Architecture)的主要收益有哪些?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: microservices, cicd)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb66623565038f4132bd | 官方: 是 | 付费: 否

答案:

答案- 小团队可围绕服务边界并行开发,提升交付效率。

  • 服务可独立部署与独立扩缩容,能单独放大“热服务”。
  • 故障隔离更强:单个服务异常不必导致全站不可用。
  • 技术栈更灵活:不同服务可按需求选择语言/数据库/中间件。
  • 更利于持续交付与快速迭代(配合 CI/CD 与自动化测试)。

618. 如何开始落地微服务:为什么说没有“标准答案”?实践上可以遵循哪些共性原则?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: microservices, system-design)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb6a623565038f4134be | 官方: 是 | 付费: 否

答案:

答案微服务没有放之四海皆准的“标准套路”,因为拆分粒度、团队结构、业务复杂度与基础设施成熟度都不同。实践中通常遵循一些共性原则:以业务能力划分边界、API 优先、自动化测试与 CI/CD(Continuous Integration/Continuous Deployment)、可观测性(Observability)先行、渐进式拆分(从模块化单体到微服务)。

  • 先把单体做“模块化/分层”,再逐步抽出最痛的领域(高变更/高负载/强隔离需求)。
  • 把平台能力(网关、服务发现、配置中心、日志/指标/追踪)作为基础设施先补齐。

619. 微服务如何拆分(Decompose)?什么是“按业务能力拆分”?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: ddd, microservices;标签: decomposition, business-capability)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb6a623565038f4134c2 | 官方: 是 | 付费: 否

答案:

答案常见做法是按“业务能力(Business Capability)”拆分:即企业为了向用户提供价值所执行的一类稳定能力,比如电商里的商品目录、库存、订单、配送、用户等。每个能力形成独立服务,由对应团队长期负责。

  • 优势:边界更稳定、API 更清晰,团队对领域更熟悉。
  • 注意:不要以技术层(controller/service/dao)或数据库表为单位拆分,那会把耦合带到分布式层面。

620. 为什么微服务要“隐藏实现细节,只暴露必要接口”?如果服务直接读别人的数据库会有什么问题?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: microservices, api, data;标签: database-per-service, contract)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb6d623565038f4136ee | 官方: 是 | 付费: 否

答案:

答案微服务边界依赖稳定的契约(Contract,API/事件)。如果 Service B 直接访问 Service A 的数据库,相当于把私有实现变成公共依赖:

  • Service A 的 schema 变更会直接破坏 Service B,导致发布必须协调。
  • 无法判断谁在用哪些表/字段,降低演进与重构能力。
  • 权限、安全与数据一致性更难治理,形成“隐形单体”。
    正确做法是通过 Service A 的 API/事件获取数据,由 Service A 对外提供稳定契约,并通过测试保证兼容。

621. 服务间通信协议(Communication Protocol)怎么选?为什么要避免过于“脆弱/强绑定”的协议?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: rest, grpc, messaging)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb6f623565038f4138ef | 官方: 是 | 付费: 否

答案:

答案协议选择要兼顾:跨语言互通、演进兼容、性能与可观测性。常见是 HTTP/REST、gRPC、消息队列(Message Queue,事件驱动)。
如果选用强绑定或难兼容的协议(例如强依赖特定运行时/序列化方式),会限制消费者技术栈,并增加向后兼容难度,导致升级成本飙升。

  • 建议:对外 REST 兼容性好;内部高性能可选 gRPC;异步解耦用事件/消息。

622. 什么是“去中心化(Decentralize)”在微服务里的含义?团队职责如何变化?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: devops, microservices;标签: ownership, you-build-it-you-run-it)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb6f623565038f4138f2 | 官方: 是 | 付费: 否

答案:

答案去中心化强调“你构建,你运行(You build it, you run it)”:服务团队不仅写代码,还负责部署、监控、告警、故障处理与持续改进。
这种模式减少跨团队交接,提高服务质量与响应速度;但也要求完善的平台能力与文档,让他人能快速理解与协作(内部开源模式、PR 协作)。

623. 为什么不建议把大量业务逻辑塞进“中央消息总线(Central Message Bus)”?更好的事件驱动实践(Event-Driven Practice)是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: event-driven, messaging, rabbitmq, kafka)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb72623565038f413aea | 官方: 是 | 付费: 否

答案:

答案中央总线如果承载越来越多业务逻辑,会逐渐“懂太多领域知识(Domain Knowledge)”,变成新的耦合中心(Coupling Center):任何变更都需要跨团队协调,演进困难。
更好的方式是:总线只负责路由/投递,业务逻辑放在服务内;通过领域事件(Domain Events)与清晰的事件契约(Event Contract)实现解耦,并配套幂等(Idempotency)、重试(Retry)、DLQ(Dead Letter Queue)与版本演进策略。

624. 什么是消费者驱动契约(Consumer-Driven Contracts, CDC)?它如何帮助微服务(Microservices)安全发布?

  • 知识点: 后端 / 测试 / 系统设计/架构 / UI/UX 设计 (主题: testing, api, microservices;标签: cdc, contract-testing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb72623565038f413aed | 官方: 是 | 付费: 否

答案:

答案CDC 由“消费者(Consumer)”描述对“提供者(Provider)API”的期望(请求/响应字段、状态码、语义等),提供者在发布前必须通过所有消费者契约测试(Contract Test),确保变更不破坏依赖方。
它能让提供者清楚有哪些下游在依赖、依赖了什么,从而支持独立发布与渐进升级,减少联调成本。

625. 生产环境中如何修改已有微服务(Microservices)API 而不影响依赖方?请给出两种策略。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api, microservices;标签: versioning, backward-compatibility)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb76623565038f413d3e | 官方: 是 | 付费: 否

答案:

答案- API 版本化(API Versioning):同时保留 v1/v2,让依赖方按自己的节奏迁移;缺点是多版本维护成本高。

  • 同服务内新增 endpoint:保持单一版本,但提供新接口;当所有依赖方迁移后再删除旧接口。
    无论哪种方式,都需要兼容性测试(Compatibility Testing)(CDC)、灰度发布(Canary Release)与可回滚策略(Rollback Strategy)。

626. 为什么微服务(Microservices)需要统一标准(如错误处理、API 风格)?常用工具/方法有哪些?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: swagger, openapi, api)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb76623565038f413d4b | 官方: 是 | 付费: 否

答案:

答案多团队并行时,如果缺少标准,每个服务会用不同的错误码/字段/鉴权方式,导致客户端集成成本高、可观测性(Observability)差、重复代码多。统一标准能降低协作摩擦并提升一致性。

  • API Style Guide(例如 PayPal 风格指南)
  • OpenAPI/Swagger 做设计与文档
  • 统一错误码、TraceId、分页/过滤规范
  • 公共 SDK 需谨慎,避免过度绑定实现细节

627. 为什么说微服务(Microservices)并不会“天然更可靠”?常见失败来源有哪些?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: resilience, microservices)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696deb79623565038f413f46 | 官方: 是 | 付费: 否

答案:

答案微服务把单体(Monolith)内部调用变成网络调用,失败面增大:网络抖动(Network Jitter)、超时(Timeout)、重试风暴(Retry Storm)、下游雪崩(Cascade Failure)、配置错误等都会放大故障。

  • 下游服务不可用/变慢
  • 网络超时与丢包
  • 资源耗尽(线程池/连接池)
  • 不当重试导致放大流量
  • 数据一致性与幂等处理缺失

628. Serverless 为什么强调“无状态(Stateless)”?状态一般放在哪里?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 (主题: serverless, state-management, databases;标签: Stateless, State)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f37 | 官方: 是 | 付费: 否

答案:

答案函数无状态的好处是可水平扩展(Horizontal Scaling):任意一次调用都不依赖本地内存中的历史数据,平台就能在多实例并发执行。状态通常外置到托管服务,例如数据库(Database)(DynamoDB/PostgreSQL)、缓存(Cache)(Redis)、对象存储(Object Storage)(S3)、消息队列(Message Queue)或工作流编排服务(Workflow Orchestration)(Step Functions/Durable Functions),从而保证可扩展性与容错。

629. 解释什么是 Cold Start(冷启动),常见成因有哪些?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: serverless, performance;标签: Cold Start, Latency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f3a | 官方: 是 | 付费: 否

答案:

答案Cold Start(冷启动)指函数在一段时间无调用后首次触发时,需要初始化运行时环境(拉取镜像/加载运行时/依赖/建立网络)导致的额外延迟。常见成因包括:函数包过大、依赖初始化耗时、语言运行时启动慢(如 JVM(Java虚拟机))、VPC(虚拟私有云)/网络冷启动、并发突增触发新实例创建等。

630. 如何缓解 Cold Start(冷启动)?请给出 3-5 个可落地的方法。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: serverless, performance, aws-lambda;标签: Optimization, Cold Start)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f3d | 官方: 是 | 付费: 否

答案:

答案常见手段:1)减少包体与依赖(按需打包、分层/Layer);2)把重初始化移到函数外(复用连接、懒加载);3)使用预置并发/常驻实例(如 Provisioned Concurrency(预置并发));4)缩短网络路径(尽量避免不必要的 VPC(虚拟私有云)绑定,或优化 VPC 方案);5)拆分大函数为更小的职责单元,减少启动与执行时间。

631. Serverless(无服务器)函数的执行时长与资源限制会影响哪些架构决策?举例说明。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: serverless, architecture, scalability;标签: Limits, Design)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f60 | 官方: 是 | 付费: 否

答案:

答案多数 FaaS(函数即服务)对单次执行时长、内存/CPU(中央处理器)、并发与临时磁盘都有上限(如 Lambda(AWS Lambda) 15 分钟)。因此长任务要拆分:用队列分片并行处理、用工作流编排把步骤拆成多段、或把重计算放到容器/K8s(Kubernetes)/批处理平台。资源受限也会影响依赖与数据处理方式:例如流式处理替代一次性加载大文件,或把大附件放到对象存储再引用。

632. Serverless(无服务器)如何实现自动扩缩容?它与传统手动扩容的差别是什么?

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: serverless, autoscaling;标签: Scaling, Concurrency)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f71 | 官方: 是 | 付费: 否

答案:

答案Serverless(无服务器)以事件量驱动扩缩容:平台根据并发请求/队列积压等信号自动创建更多函数实例,负载下降时回收实例甚至缩到零。与传统扩容相比,团队不需要管理实例生命周期、镜像发布与容量预测,但需要关注并发上限、下游依赖(数据库/第三方 API(应用程序接口))是否会被放大流量“打爆”,并通过限流、队列缓冲和熔断进行保护。

633. Serverless(无服务器)中如何做可观测性(日志、指标、链路追踪)?常见做法有哪些?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: serverless, observability, monitoring;标签: Logging, Tracing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dece0623565038f416f83 | 官方: 是 | 付费: 否

答案:

答案由于函数分布式且事件驱动,建议:1)结构化日志(带 requestId(请求标识)/traceId(追踪标识));2)集中化日志与检索(如 CloudWatch(AWS CloudWatch)/ELK(Elasticsearch-Logstash-Kibana));3)关键指标:错误率、延迟、并发、重试次数、队列积压;4)分布式追踪(X-Ray(AWS X-Ray)/Application Insights(应用程序洞察)/OpenTelemetry(开放遥测))串联跨服务调用;5)基于阈值与异常检测做告警,并把告警接入值班/工单系统。

634. EDA(事件驱动架构)里的“事件”通常指什么?事件和消息有什么区别?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, schema, event-sourcing;标签: event modeling, schema, versioning)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188e2 | 官方: 是 | 付费: 否

答案:

答案事件通常表示“已经发生的事实”,例如 UserRegistered(用户已注册)、OrderPaid(订单已支付),强调不可变与可追溯;消息更偏向“传递载体”,可以承载命令、事件或通知。
在落地上,事件会以消息的形式在队列/Topic(主题)中流转,但建模时建议把事件当作领域事实,关注事件名、版本、schema(模式)、幂等键与可重放性。

635. EDA(事件驱动架构)的核心组件有哪些?各自职责是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, observability, microservices;标签: producer, consumer, broker, schema registry)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188e8 | 官方: 是 | 付费: 否

答案:

答案典型组件包括:事件生产者(Producer(生产者))、事件通道(Event Bus/Broker(事件总线/代理),如 Kafka(Apache Kafka))、事件消费者(Consumer(消费者))、以及可选的 Schema Registry(模式注册表)、事件存储与监控体系。
Producer(生产者)负责产生领域事件并发布;Broker(代理)负责持久化、分发与消费位点管理;Consumer(消费者)负责订阅并处理事件;Schema Registry(模式注册表)管 schema(模式)兼容;可观测性负责追踪链路、延迟与失败率。

636. 为什么说 EDA(事件驱动架构)更“松耦合”?它带来哪些工程收益?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: kafka, microservices, messaging;标签: loose coupling, scalability, fault isolation)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188f1 | 官方: 是 | 付费: 否

答案:

答案松耦合(Loose Coupling)的关键在于:生产者(Producer)只面向 Topic/事件契约(Event Contract),不需要直接依赖消费者(Consumer)的 API;消费者可独立扩缩、独立发布,新增订阅者不需要改生产者。
工程收益包括:更容易拆分微服务(Microservices)边界、提升扩展性(Scalability)与容错性(Fault Tolerance)(失败隔离(Failure Isolation))、更适合实时业务(流式处理(Stream Processing))、以及更方便做异步工作流(Asynchronous Workflow)与系统集成(System Integration)。

637. EDA(Event-Driven Architecture)中常见的一致性模型(Consistency Model)是什么?如何应对最终一致性(Eventual Consistency)的挑战?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, saga, cdc;标签: eventual consistency, idempotency, outbox)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188f8 | 官方: 是 | 付费: 否

答案:

答案EDA 常采用最终一致性(Eventual Consistency):各服务通过事件异步推进状态,短时间内可能出现读到旧数据的情况。
应对方法包括:幂等消费(Idempotent Consumption)(去重键/幂等表)、事件版本管理(Event Versioning)、补偿事务(Compensating Transaction)(SAGA)、Outbox/CDC 保证事件与本地事务一致发布,以及用“可接受的延迟”定义业务 SLA(Service Level Agreement)。

638. 解释一下 Event Sourcing 和 CQRS(Command Query Responsibility Segregation),它们在 EDA 里如何配合?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, cqrs, event-sourcing;标签: CQRS, Event Sourcing, read model)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f4188fb | 官方: 是 | 付费: 否

答案:

答案Event Sourcing(事件溯源)把系统状态变化记录为一串事件(事件日志(Event Log)是事实源),需要时可通过重放事件重建状态。
CQRS 将写(Command)与读(Query)分离:写侧产生事件,读侧用事件构建查询友好的视图(Read Model)。在 EDA 中,Kafka/事件流可承载事件日志,读模型由消费者异步维护。

639. 在 EDA 里“事件顺序(Event Ordering)”为什么难?常见解决策略有哪些?

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: kafka, stream-processing;标签: ordering, partitioning, retries)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418907 | 官方: 是 | 付费: 否

答案:

答案分布式系统里事件可能并发产生、跨分区传输、重试导致重复投递,因此全局有序(Global Ordering)代价很高。
常见策略:按业务键分区(同一 key 进入同一分区保证局部有序(Partial Ordering))、为事件加序列号/版本号、消费者做乱序缓冲与重排、以及把必须强一致的流程收敛到同一聚合(Aggregate)或同一写侧。

640. 什么是 Pub/Sub(Publish/Subscribe)?它和传统同步 RPC(Remote Procedure Call)的核心差异是什么?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, rabbitmq, microservices;标签: pubsub, rpc, async)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f41890a | 官方: 是 | 付费: 否

答案:

答案Pub/Sub 是发布-订阅模式:发布者把事件发到 Topic,订阅者按需消费;发布者不需要知道订阅者是谁。
与同步 RPC 相比:Pub/Sub 异步、解耦、更利于削峰与重放;RPC 直接调用、实时返回、但强依赖对方可用性与接口稳定性。系统常混用:关键读写走 RPC,异步扩散与集成走事件。

641. 为什么 Kafka 常被用作 EDA 的基础设施?它提供了哪些关键能力?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, streaming;标签: Kafka, event streaming, offset)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f41890d | 官方: 是 | 付费: 否

答案:

答案Kafka 适合做事件流(Event Stream)底座,因为它是分布式、可水平扩展的日志系统(Log System),提供高吞吐(High Throughput)、持久化(Persistence)、分区(Partitioning)与消费位点(offset)管理。
关键能力包括:Topic 分区(Partition)扩展、按分区顺序写入、消费者组(Consumer Group)并行消费、可重放历史事件、以及较强的容错(副本(Replica)、ISR(In-Sync Replica))。这些特性让它既能做消息(Message),也能做事件日志(Event Log)。

642. 什么是 Schema Registry(Schema 注册表)?为什么它对 EDA(Event-Driven Architecture)很重要?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, schema;标签: schema registry, compatibility, contract)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418910 | 官方: 是 | 付费: 否

答案:

答案Schema Registry 用于集中管理事件的 schema(模式)(如 Avro/Protobuf/JSON Schema),并校验 schema 演进兼容性(向后(Backward)/向前(Forward)/完全兼容(Full Compatibility))。
它的重要性在于:事件是跨团队的“契约”,schema 演进不可控会导致消费者崩溃或数据污染。通过版本与兼容规则,能在不停机的情况下演进事件格式。

643. EDA 里如何做可靠投递?至少一次(At-least-once)、至多一次(At-most-once)、恰好一次(Exactly-once)各有什么取舍?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, reliability;标签: delivery semantics, idempotency, exactly-once)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418919 | 官方: 是 | 付费: 否

答案:

答案至少一次(At-least-once)最常见:允许重复但不丢消息,需要消费者幂等(Idempotency);至多一次(At-most-once)可能丢消息但延迟低;恰好一次(Exactly-once)语义最强但实现复杂,通常依赖事务(Transaction)/幂等生产者(Idempotent Producer)/状态一致性(State Consistency)。
工程上常用“至少一次 + 幂等 + 去重”实现可控一致性;对账/结算类可引入事务性写入与幂等键(Idempotency Key),尽量把强一致需求收敛在边界内。

644. EDA 系统的可观测性(Observability)怎么做?需要关注哪些指标?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: kafka, observability, opentelemetry;标签: monitoring, consumer lag, tracing)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418930 | 官方: 是 | 付费: 否

答案:

答案EDA 的可观测性要覆盖:生产端(Producer Side)、Broker(消息代理)、消费端与业务链路。常见手段包括集中日志、指标监控、分布式追踪(traceId/correlationId),以及对关键 Topic 建立告警。
重点指标:生产/消费吞吐(Throughput)、消费滞后(Lag)、端到端延迟(End-to-End Latency)、失败率与重试次数、DLQ(Dead Letter Queue)堆积、以及下游处理耗时分布。

645. EDA 的典型缺点有哪些?在系统设计面试里怎么讲取舍?

  • 知识点: 后端 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: kafka, system-design;标签: trade-offs, complexity, DLQ)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418947 | 官方: 是 | 付费: 否

答案:

答案缺点主要是:运维复杂度提升(broker、schema、重试、DLQ)、事件顺序与一致性更难、调试链路更复杂、以及事件模型设计要求更高。
面试里可以用“业务需要实时扩散/高并发解耦”来 justify EDA,同时说明如何控制复杂度:明确事件契约(Event Contract)、幂等与去重、DLQ+回放(Replay)、以及把强一致路径留给同步接口或聚合写侧。

646. 在企业规模落地 EDA 时,为什么需要“事件建模”与治理(Governance)?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: kafka, governance, schema;标签: event modeling, governance, PII)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418953 | 官方: 是 | 付费: 否

答案:

答案事件是跨团队共享的接口,如果没有统一命名、版本策略、schema 兼容规则与数据分级,很容易出现“事件泛滥、语义不清、消费者被动升级”的问题。
治理通常包括:领域事件(Domain Event)与集成事件(Integration Event)区分、事件目录/文档、Schema Registry 兼容策略、敏感字段脱敏与加密、以及 Topic 权限与审计(Audit)。

647. Kafka Streams / Flink(Apache Flink) 在 EDA(Event-Driven Architecture,事件驱动架构) 里通常扮演什么角色?

  • 知识点: 后端 / 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: kafka, flink, stream-processing;标签: stream processing, window, stateful)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696dedc6623565038f418956 | 官方: 是 | 付费: 否

答案:

答案它们是流处理引擎(Stream Processing Engine):对事件流(Event Stream)做过滤、聚合(Aggregation)、Join(连接) 、窗口计算(Windowing) 与状态管理(State Management),把“持续变化的数据”转成实时指标或下游可用的派生事件(Derived Event)。
Kafka Streams(卡夫卡流)更轻量、贴近应用侧;Flink(弗林克)更强在复杂状态、事件时间处理与大规模作业治理。选择取决于吞吐、状态大小、延迟 SLA(服务等级协议)与运维能力。

648. 说说你对单元测试(Unit Testing)和集成测试(Integration Testing)的理解。

  • 知识点: 后端 / 测试 (主题: testing, unit-test, integration-test;标签: 单元测试, 集成测试, Mock)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 696f3949120fcc15911b96c4 | 官方: 是 | 付费: 否

答案:

答案单元测试(Unit Test)验证最小可测试单元(函数(Function)/方法(Method)/类(Class))的逻辑正确性,通常用Mock(模拟对象)隔离外部依赖,强调快速、稳定、覆盖分支;集成测试(Integration Test)验证多个模块(Module)/服务(Service)/组件(Component)组合后的协作是否正确(接口契约(Interface Contract)、数据流(Data Flow)、依赖交互(Dependency Interaction)),更接近真实环境,能发现集成点问题(序列化(Serialization)、权限(Authorization)、网络(Network)、配置(Configuration)、时序(Timing))。两者目标互补:单测防“内部逻辑错”,集成测防“拼起来出问题”。

649. 你会如何设计一个符合 RESTful(REST)风格的 API(Application Programming Interface)?需要注意哪些关键点?

  • 知识点: 后端 / 操作系统与网络 / UI/UX 设计 / 编程语言基础 (主题: dotnet, api-design;标签: REST, HTTP, API)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Carsales
  • id: 697042bd120fcc1591302cad | 官方: 是 | 付费: 否

答案:

答案关键点:资源建模(Resource Modeling)(/cars/{id})、正确使用 HTTP 方法(HTTP Methods)(GET/POST/PUT/PATCH/DELETE)、无状态(Stateless)、统一返回格式(Unified Response Format)、合理状态码(HTTP Status Codes)(200/201/204/400/401/403/404/409/500)、分页/排序/过滤(Pagination/Sorting/Filtering)、版本管理(Versioning)(/v1 或 header)、幂等性(Idempotency)(PUT/DELETE)、鉴权与限流(Authentication and Rate Limiting)。
在 .NET(.NET)中建议配合:DTO(Data Transfer Object)、Model Validation(模型验证)、ProblemDetails(问题详情)、OpenAPI(开放API)/Swagger(Swagger)、日志(Logging)与 TraceId(TraceId)。
AnswerKey points: resource-oriented endpoints, correct HTTP verbs, statelessness, consistent response schema, proper status codes, pagination/sort/filter, versioning, idempotency, auth & rate limiting.

答题要点:面向资源的端点、正确的HTTP动词、无状态性、一致的响应模式、恰当的状态码、分页/排序/过滤、版本控制、幂等性、认证与速率限制。
In .NET: DTOs, validation, ProblemDetails, Swagger/OpenAPI, logging + trace IDs.
在 .NET 中:DTO、验证、ProblemDetails、Swagger/OpenAPI、日志与追踪ID。

650. 如何通过 API(Application Programming Interface)把 Databricks(数据砖)与其他数据源(Data Source)/系统(System)集成?

  • 知识点: 后端 / 数据工程与数据科学/AI (主题: databricks, rest-api, jdbc, odbc, integration, orchestration;标签: Databricks, Integration)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69708bca120fcc1591373f2f | 官方: 否 | 付费: 否

答案:

答案编排层(Orchestration Layer)可用 Databricks REST API(Application Programming Interface)/CLI(Command-Line Interface)进行作业触发(Job Triggering)、集群管理(Cluster Management)与工作区操作(Workspace Operations);数据层(Data Layer)可通过 JDBC(Java Database Connectivity)/ODBC(Open Database Connectivity)连接外部数据库(External Database),或用云对象存储(Cloud Object Storage)/消息队列(Message Queue)接入。
更复杂的场景可用 ADF(Azure Data Factory)/Airflow(Apache Airflow)/Glue(AWS Glue) 调用 Databricks(Databricks) 任务;在 Notebook(Notebook) 中实现增量抽取(Incremental Extraction)、幂等写入(Idempotent Write)与回溯机制(Backfill Mechanism)。

651. 请描述你对 RESTful API(RESTful Application Programming Interface)的理解。

  • 知识点: 后端 / 操作系统与网络 / UI/UX 设计 (主题: api, http, rest;标签: rest, http, api-design)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Telstra
  • id: 69709b3a120fcc15913a3d3f | 官方: 是 | 付费: 否

答案:

答题要点- 资源建模(Resource Modeling):/resources/{id}(资源标识符,Resource Identifier),用HTTP方法(HTTP Method)表达动作(GET/POST/PUT/PATCH/DELETE)

  • 无状态:请求携带必要上下文(Auth、分页、过滤)
  • 契约:状态码、错误码、幂等性、版本管理
  • 安全与性能:鉴权、限流、缓存、OpenAPI 文档
    示例回答RESTful API(Representational State Transfer API)以资源为中心,通过标准HTTP(HyperText Transfer Protocol)方法完成CRUD(Create, Read, Update, Delete),并保持无状态(Stateless)。设计时我会规范URL(Uniform Resource Locator)与状态码(Status Code),明确错误响应(Error Response)与幂等性(Idempotency),必要时做版本管理(Versioning);同时配套鉴权(Authentication)、限流(Rate Limiting)、缓存(Caching)与OpenAPI(OpenAPI Specification)文档,方便前后端与第三方协作。

652. 请实现一个 API 来管理用户数据(增删改查)。

  • 知识点: 后端 / 编程语言基础 (主题: api, python, rest;标签: fastapi, crud, api)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • 公司: Telstra
  • id: 69709b58120fcc15913a5a6b | 官方: 是 | 付费: 否

答案:

设计要点- 定义资源:/users/{user_id},选择合适HTTP方法(HTTP Method)

  • 输入校验:使用DTO/Schema(例如Pydantic)
  • 错误处理:404/400 等标准状态码
  • 可扩展:把内存字典替换为数据库;加鉴权与日志
    示例代码(FastAPI)from fastapi import FastAPI, HTTPException
    from pydantic import BaseModel

    from pydantic import BaseModel

app = FastAPI()

app = FastAPI()

class UserIn(BaseModel):

class UserIn(BaseModel):
name: str
name: str

users: dict[int, str] = {}

users: dict[int, str] = {}

@app.post("/users/{user_id}")

@app.post("/users/{user_id}")
def create_or_update_user(user_id: int, payload: UserIn):
def create_or_update_user(user_id: int, payload: UserIn):
users[user_id] = payload.name
users[user_id] = payload.name
return {"user_id": user_id, "name": users[user_id]}
return {"user_id": user_id, "name": users[user_id]}

@app.get("/users/{user_id}")

@app.get("/users/{user_id}")
def get_user(user_id: int):
def get_user(user_id: int):
if user_id not in users:
if user_id not in users:
raise HTTPException(status_code=404, detail="User not found")
raise HTTPException(status_code=404, detail="User not found")
return {"user_id": user_id, "name": users[user_id]}
return {"user_id": user_id, "name": users[user_id]}

@app.delete("/users/{user_id}")

@app.delete("/users/{user_id}")
def delete_user(user_id: int):
def delete_user(user_id: int):
if user_id not in users:
if user_id not in users:
raise HTTPException(status_code=404, detail="User not found")
raise HTTPException(status_code=404, detail="User not found")
del users[user_id]
del users[user_id]
return {"message": "deleted"}
return {"message": "deleted"}

653. 说一下 Spring(Spring) 的事务(Transaction)隔离?

  • 知识点: 后端 / 数据库 / 编程语言基础 (主题: java, spring, transaction;标签: Spring, Transaction, Isolation)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c61c | 官方: 是 | 付费: 否

答案:

答案
Spring(Spring) 有五大隔离级别(Isolation Level),默认值为 ISOLATION_DEFAULT(使用数据库的设置),其他四个隔离级别与数据库的隔离级别一致:

  • ISOLATION_DEFAULT:用底层数据库的设置隔离级别,数据库设置的是什么我就用什么。
  • ISOLATION_READ_UNCOMMITTED:未提交读,最低隔离级别,事务未提交前,就可被其他事务读取(会出现幻读、脏读、不可重复读)。
  • ISOLATION_READ_COMMITTED:提交读,一个事务提交后才能被其他事务读取到(会造成幻读、不可重复读),SQL Server 的默认级别。
  • ISOLATION_REPEATABLE_READ:可重复读,保证多次读取同一个数据时,其值都和事务开始时的内容是一致,禁止读取到别的事务未提交的数据(会造成幻读),MySQL 的默认级别。
  • ISOLATION_SERIALIZABLE:序列化,代价最高最可靠的隔离级别,该隔离级别能防止脏读、不可重复读、幻读。

脏读(Dirty Read):表示一个事务(Transaction)能够读取另一个事务中还未提交的数据。比如,某个事务尝试插入记录 A,此时该事务还未提交,然后另一个事务尝试读取到了记录 A。

不可重复读(Non-repeatable Read):是指在一个事务内,多次读取同一数据。

幻读(Phantom Read):指同一个事务内多次查询返回的结果集不一样。比如同一个事务 A 第一次查询时只有 n 条记录,但是第二次同一个事务 A 查询却有 n+1 条记录,这就好像产生了幻觉。发生幻读的原因也是另外一个事务新增或删除或者修改了第一个事务查询结果集里面的数据,同一个记录的数据内容被修改了,所有数据行的记录就变多或者变少了。

654. 说一下 Spring MVC(Spring MVC) 运行流程?

  • 知识点: 后端 / 编程语言基础 (主题: java, spring, spring-mvc;标签: Spring MVC, DispatcherServlet, Flow)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c621 | 官方: 是 | 付费: 否

答案:

答案

  • Spring MVC 先将请求发送给 DispatcherServlet。
  • DispatcherServlet 查询一个或多个 HandlerMapping,找到处理请求的 Controller。
  • DispatcherServlet 再把请求提交到对应的 Controller。
  • Controller 进行业务逻辑处理后,返回一个 ModelAndView。
  • Dispatcher 查询一个或多个 ViewResolver 视图解析器,找到 ModelAndView 对象指定的视图对象。
  • 视图对象负责渲染返回给客户端。

655. 什么是 Spring Boot(Spring Boot)?

  • 知识点: 后端 / 编程语言基础 (主题: java, springboot;标签: Spring Boot, Definition)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c632 | 官方: 是 | 付费: 否

答案:

答案
Spring Boot(Spring Boot) 是为 Spring(Spring) 服务的,是用来简化新 Spring(Spring) 应用的初始搭建以及开发过程的。

656. 为什么要用 Spring Boot(Spring Boot)?

  • 知识点: 后端 / 编程语言基础 (主题: java, springboot;标签: Spring Boot, Benefits)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c636 | 官方: 是 | 付费: 否

答案:

答案

  • 配置简单
  • 独立运行
  • 自动装配
  • 无代码生成和 xml 配置
  • 提供应用监控
  • 易上手
  • 提升开发效率

657. Spring Boot(Spring Boot) 核心配置文件是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, springboot;标签: Spring Boot, Config)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c63b | 官方: 是 | 付费: 否

答案:

答案
Spring Boot(Spring Boot) 核心的两个配置文件:

  • bootstrap(.yml 或者 .properties):bootstrap 由父 ApplicationContext 加载的,比 application 优先加载,且 bootstrap 里面的属性不能被覆盖。
  • application(.yml 或者 .properties):用于 Spring Boot 项目的自动化配置。

658. Spring Boot(Spring Boot) 配置文件有哪些类型?它们有什么区别?

  • 知识点: 后端 / 编程语言基础 (主题: java, springboot;标签: Spring Boot, YAML, Properties)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c641 | 官方: 是 | 付费: 否

答案:

答案
配置文件有 .properties(.properties) 格式和 .yml(.yml) 格式,它们主要的区别是书法风格不同。

.properties(.properties) 配置如下:

spring. RabbitMQ. port=5672

spring. RabbitMQ. port=5672
.yml(.yml) 配置如下:

spring:

spring:
RabbitMQ:
RabbitMQ:
port: 5672
port: 5672
.yml 格式不支持 @PropertySource(PropertySource)注解导入。

659. Spring Boot(Spring Boot)有哪些方式可以实现热部署?

  • 知识点: 后端 / 编程语言基础 (主题: java, springboot;标签: Spring Boot, Hot Reload, DevTools)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c648 | 官方: 是 | 付费: 否

答案:

答案

  • 使用 devtools 启动热部署,添加 devtools 库,在配置文件中把 spring.devtools.restart.enabled 设置为 true;
  • 使用 IntelliJ Idea 编辑器,勾上自动编译或手动重新编译。

660. JPA(JPA)和 Hibernate(Hibernate)有什么区别?

  • 知识点: 后端 / 编程语言基础 (主题: java, jpa, hibernate;标签: JPA, Hibernate)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c64b | 官方: 是 | 付费: 否

答案:

答案
JPA(JPA)全称 Java Persistence API(Java Persistence API),是 Java 持久化接口规范;Hibernate(Hibernate)属于 JPA(JPA)的具体实现。

661. 什么是 Spring Cloud(Spring Cloud)?

  • 知识点: 后端 / DevOps/云 / 编程语言基础 (主题: java, springcloud;标签: Spring Cloud, Definition)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c64e | 官方: 是 | 付费: 否

答案:

答案
Spring Cloud(Spring Cloud)是一系列框架的有序集合。它利用 Spring Boot(Spring Boot)的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等,都可以用 Spring Boot(Spring Boot)的开发风格做到一键启动和部署。

662. Spring Cloud(Spring Cloud)断路器的作用是什么?

  • 知识点: 后端 / DevOps/云 / 编程语言基础 (主题: java, springcloud;标签: Circuit Breaker, Resilience)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c652 | 官方: 是 | 付费: 否

答案:

答案
在分布式架构中,断路器模式的作用也是类似的,当某个服务单元发生故障(类似用电器发生短路)之后,通过断路器的故障监控(类似熔断保险丝),向调用方返回一个错误响应,而不是长时间的等待。这样就不会使得线程因调用故障服务被长时间占用不释放,避免了故障在分布式系统中的蔓延。

663. Spring Cloud(Spring Cloud)的核心组件有哪些?

  • 知识点: 后端 / DevOps/云 / 编程语言基础 (主题: java, springcloud;标签: Eureka, Feign, Ribbon, Hystrix, Zuul)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c657 | 官方: 是 | 付费: 否

答案:

答案

  • Eureka:服务注册于发现。
  • Feign:基于动态代理机制,根据注解和选择的机器,拼接请求 url 地址,发起请求。
  • Ribbon:实现负载均衡,从一个服务的多台机器中选择一台。
  • Hystrix:提供线程池,不同的服务走不同的线程池,实现了不同服务调用的隔离,避免了服务雪崩的问题。
  • Zuul:网关管理,由 Zuul 网关转发请求给对应的服务。

664. 为什么要使用 Hibernate(Hibernate)?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate, orm;标签: Hibernate, ORM, Benefits)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c65e | 官方: 是 | 付费: 否

答案:

答案

  • Hibernate 是对 JDBC 的封装,大大简化了数据访问层的繁琐的重复性代码。
  • Hibernate 是一个优秀的 ORM 实现,很多程度上简化了 DAO 层的编码功能。
  • 可以很方便的进行数据库的移植工作。
  • 提供了缓存机制,是程序执行更改的高效。

665. 什么是 ORM(ORM)框架?

  • 知识点: 后端 / 编程语言基础 (主题: java, orm, hibernate;标签: ORM, Mapping)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c661 | 官方: 是 | 付费: 否

答案:

答案
ORM(ORM)(Object Relation Mapping)对象关系映射,是把数据库中的关系数据映射成为程序中的对象。

使用 ORM(ORM)的优点:提高了开发效率降低了开发成本,开发更简单更对象化,可移植更强。

666. Hibernate(Hibernate)中如何在控制台查看打印的 SQL(SQL)语句?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, SQL Logging)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c664 | 官方: 是 | 付费: 否

答案:

答案
在 Config(Config)里面把 hibernate.show_sql(hibernate.show_sql)设置为 true 就可以。但是不建议开启,开启之后会降低程序的运行效率。

667. Hibernate(Hibernate)有几种查询方式?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Query)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c66c | 官方: 是 | 付费: 否

答案:

答案
三种:hql(Hibernate Query Language)、原生 SQL(Structured Query Language)、条件查询 Criteria(Criteria Query)。

668. Hibernate 实体类(Entity)可以被定义为 final 吗?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Entity, final)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c66f | 官方: 是 | 付费: 否

答案:

答案
实体类可以定义为 final 类,但这样的话就不能使用 Hibernate 代理模式(Proxy Pattern)下的延迟关联(Lazy Association)提供性能了,所以不建议定义实体类为 final。

669. 在 Hibernate 中使用 Integer 和 int 做映射(Mapping)有什么区别?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Mapping, Integer, int)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c672 | 官方: 是 | 付费: 否

答案:

答案
Integer 类型为对象,它的值允许为 null;而 int 属于基础数据类型(Primitive Type),值不能为 null。

670. Hibernate 是如何工作的?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Workflow)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c67b | 官方: 是 | 付费: 否

答案:

答案

  • 读取并解析配置文件。
  • 读取并解析映射文件,创建 SessionFactory。
  • 打开 Session。
  • 创建事务。
  • 进行持久化操作。
  • 提交事务。
  • 关闭 Session。
  • 关闭 SessionFactory。

672. 说一下 Hibernate 的缓存机制(Cache Mechanism)?

  • 知识点: 后端 / 系统设计/架构 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Cache)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c68e | 官方: 是 | 付费: 否

答案:

答案
Hibernate 常用的缓存有一级缓存(First-level Cache)和二级缓存(Second-level Cache):

一级缓存:也叫 Session 缓存(Session Cache),只在 Session 作用范围内有效,不需要用户干涉,由 Hibernate 自身维护,可以通过:evict(object) 清除 object 的缓存;clear() 清除一级缓存中的所有缓存;flush() 刷出缓存;

二级缓存:应用级别的缓存,在所有 Session 中都有效,支持配置第三方的缓存,如:EhCache(Ehcache)。

673. Hibernate 对象有哪些状态?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Entity State)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c699 | 官方: 是 | 付费: 否

答案:

答案

  • 临时/瞬时状态:直接 new 出来的对象,该对象还没被持久化(没保存在数据库中),不受 Session 管理。
  • 持久化状态:当调用 Session 的 save/saveOrUpdate/get/load/list 等方法的时候,对象就是持久化状态。
  • 游离状态:Session 关闭之后对象就是游离状态。

674. 在 Hibernate 中 getCurrentSession 和 openSession 的区别是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate, spring;标签: Hibernate, Session)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c69d | 官方: 是 | 付费: 否

答案:

答案

  • getCurrentSession 会绑定当前线程,而 openSession 则不会。
  • getCurrentSession 事务是 Spring 控制的,并且不需要手动关闭,而 openSession 需要我们自己手动开启和提交事务。

675. Hibernate 实体类必须要有无参构造函数(No-argument Constructor)吗?为什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, hibernate;标签: Hibernate, Constructor)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c6a9 | 官方: 是 | 付费: 否

答案:

答案
Hibernate 中每个实体类必须提供一个无参构造函数,因为 Hibernate 框架要使用 reflection api(Reflection API),通过调用 Class.newInstance() 来创建实体类的实例,如果没有无参的构造函数就会抛出异常。

676. MyBatis 中 #{} 和 ${} 的区别是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, mybatis;标签: MyBatis, SQL Injection, Parameters)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c6ad | 官方: 是 | 付费: 否

答案:

答案

{} 是预编译处理,${} 是字符串替换。

在使用 #{} 时,MyBatis 会将 SQL 中的 #{} 替换成 ?,配合 PreparedStatement 的 set 方法赋值,这样可以有效的防止 SQL 注入(SQL Injection),保证程序的运行安全。

677. RowBounds 是一次性查询全部结果吗?为什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, mybatis, jdbc;标签: MyBatis, RowBounds, Fetch Size)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c6b7 | 官方: 是 | 付费: 否

答案:

答案
RowBounds 表面是在“所有”数据中检索数据,其实并非是一次性查询出所有数据,因为 MyBatis 是对 JDBC 的封装,在 JDBC 驱动中有一个 Fetch Size 的配置,它规定了每次最多从数据库查询多少条数据,假如你要查询更多数据,它会在你执行 next() 的时候,去查询更多的数据。就好比你去自动取款机取 10000 元,但取款机每次能取 2000 元,你要取 4 次才能把钱取完。只是对于 JDBC 来说,当你调用 next() 的时候会自动帮你完成查询工作。这样做的好处可以有效的防止内存溢出(Out of Memory)。

Fetch Size 官方相关文档:http://t.cn/EfSE2g3

678. MyBatis 逻辑分页(Logical Paging)和物理分页(Physical Paging)的区别是什么?

  • 知识点: 后端 / 编程语言基础 (主题: java, mybatis;标签: MyBatis, Pagination)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 6972dff118927fe79f39c6be | 官方: 是 | 付费: 否

答案:

答案

  • 逻辑分页是一次性查询很多数据,然后再在结果中检索分页的数据。这样做弊端是需要消耗大量的内存,有内存溢出的风险,对数据库压力较大。
  • 物理分页是从数据库查询指定条数的数据,这样解决了一次性全部查询所有数据的种种缺点,比如需要大量的内存,对数据库查询压力较大等问题。

679. 你是否参与过系统集成(Integration)项目?请举例说明。

  • 知识点: 后端 / 行为与软技能 (主题: integration, api, reliability;标签: integration, api)
  • 类型: behavioral | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 69782a16a39c9c5c3ab746d5 | 官方: 是 | 付费: 否

答案:

答案回答框架
回答时聚焦“集成对象 + 接口方式 + 风险控制”。例如:你集成过支付/物流/身份认证/第三方 API;说明你如何做接口契约(OpenAPI/Schema)、鉴权(OAuth/JWT/签名)、幂等与重试(Idempotency and Retry)、超时与熔断(Timeout and Circuit Breaking)、日志追踪(Correlation ID)、以及灰度发布与回滚(Canary Release and Rollback)。最后补充你如何与产品/对方团队沟通对齐并处理变更。

  • 接口设计:契约优先、版本管理、向后兼容
  • 可靠性:超时、重试、幂等、熔断/限流
  • 可观测:日志、Tracing、指标与告警
  • 交付:联调计划、环境管理、灰度/回滚

680. 以 TikTok Privacy Compliance Platform 的 Tech Lead SWE 为例,面试官最可能关注哪些能力与技术点?

  • 知识点: 后端 / 数据库 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: distributed-systems, databases, api, golang, python, nodejs;标签: tiktok, tech-lead, privacy, backend)
  • 类型: technical | 难度: medium | 子类型:
  • 分类: fullstack
  • id: 697887f9a39c9c5c3ad694ff | 官方: 是 | 付费: 否

答案:

答案Tech Lead 岗位通常会重点考察:5+ 年开发经验与 2+ 年技术带队经验;后端核心能力(分布式系统(Distributed Systems)、数据库(Database)、API 设计与演进(API Design and Evolution));强问题定位与主动推进能力(能提前识别技术风险并推动解决);跨团队沟通协作(与 PM/QA/多团队对齐节奏);以及敏捷开发(Agile Development)经验。语言/工具上常见要求是至少熟练一种通用语言并能做性能优化(Performance Optimization)与线上排障,例如 Golang、Python、Node.js。

681. Write a function to check if one string is a subsequence of another string.

编写一个函数,检查一个字符串是否是另一个字符串的子序列。
  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 / 行为与软技能 (主题: strings, files, hashmap;标签: Backend, Java/Kotlin/Python)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • 公司: Atlassian
  • id: 6979de50c8f1f94b6462c75b | 官方: 是 | 付费: 否

答案:

双指针(Two Pointers):i 指向子序列串,j 指向母串。遍历母串,遇到相等字符就 i++;最终 i 到达末尾则说明是子序列。时间 O(n),空间 O(1)。

682. Devise a Python method to count the number of lines in a 100 GB log file.

设计一个 Python 方法,统计一个 100 GB 日志文件中的行数。
  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 / 行为与软技能 (主题: strings, files, hashmap;标签: Backend, Java/Kotlin/Python)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • 公司: Atlassian
  • id: 6979de50c8f1f94b6462c75e | 官方: 是 | 付费: 否

答案:

用分块读取(Chunked Reading)避免把 100GB 文件读入内存:按固定 buffer 读取 bytes/文本块,统计每块里的换行符 '\n' 数量并累加。比逐行迭代更高效且更省内存。

683. Write a function to return the top N frequent words and their frequencies from a given paragraph string, and determine the function’s run-time.

编写一个函数,从给定的段落字符串中返回出现频率最高的前 N 个单词及其频率,并确定该函数的运行时间。
  • 知识点: 后端 / 算法与数据结构 / 编程语言基础 / 行为与软技能 (主题: strings, files, hashmap;标签: Backend, Java/Kotlin/Python)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • 公司: Atlassian
  • id: 6979de50c8f1f94b6462c761 | 官方: 是 | 付费: 否

答案:

分词(Tokenization)→用哈希表(Hash Table)统计词频→取 Top N:可对唯一词 m 做排序 O(m log m),或用最小堆(Min Heap)做到 O(m log N)。总复杂度取决于分词成本与 m 的大小。

684. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在Afterpay BNPL(Buy Now, Pay Later)中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: afterpay, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Afterpay (Block)
  • id: 69b3791f58d557c902b977fc | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

685. 解释 RESTful API 设计的最佳实践,以及在Airbnb Platform中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: airbnb, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 爱彼迎
  • id: 69b3792158d557c902b97969 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

686. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在ANZ Plus中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: anz, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 澳新银行
  • id: 69b3793a58d557c902b990ea | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

687. 解释 RESTful API 设计的最佳实践,以及在iOS中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: apple, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 苹果
  • id: 69b3793c58d557c902b99289 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

688. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在Jira中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: atlassian, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: design
  • 公司: Atlassian
  • id: 69b3794c58d557c902b99ec7 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

689. 解释 RESTful API 设计的最佳实践,以及在Baidu Search中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: baidu, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 百度
  • id: 69b3796858d557c902b9b725 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

690. 什么是事件驱动架构(EDA, Event-Driven Architecture)?在Mining Operations中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: bhp, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 必和必拓集团
  • id: 69b3797758d557c902b9c228 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

691. 解释 RESTful API 设计的最佳实践,以及在Square POS中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: block, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Block(原 Square)
  • id: 69b3798658d557c902b9cca3 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

692. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在Booking.com中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: booking, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Booking.com
  • id: 69b3798e58d557c902b9d2ba | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

693. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在Buildkite Pipelines中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: buildkite, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Buildkite
  • id: 69b3799858d557c902b9d96e | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

694. 解释 RESTful API 设计的最佳实践,以及在TikTok中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: bytedance, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 字节跳动
  • id: 69b379b258d557c902b9edb4 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

695. 什么是事件驱动架构(EDA)?在Canva Editor中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: canva, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 可画
  • id: 69b379e858d557c902ba1182 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

696. 什么是事件驱动架构(EDA)?在CommBank App中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: cba, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Commonwealth Bank of Australia
  • id: 69b37a1058d557c902ba2a7a | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

697. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在CDN(Content Delivery Network)中如何应用。

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: cloudflare, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Cloudflare
  • id: 69b37a1358d557c902ba2da7 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

698. 什么是事件驱动架构(EDA)?在Cochlear Implants中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: cochlear, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Cochlear
  • id: 69b37a2b58d557c902ba3cdd | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

699. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在Coinbase Exchange中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: coinbase, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Coinbase
  • id: 69b37a3858d557c902ba4408 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

700. 什么是事件驱动架构(EDA)?在Coles Online中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: coles, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Coles Group
  • id: 69b37a4758d557c902ba4e45 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

701. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在DiDi Ride-hailing中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: didi, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: 滴滴出行
  • id: 69b37a7758d557c902ba6f33 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

702. What’s the use of Middleware in Django?

Django 中的中间件有什么用途?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72bb | 官方: 否 | 付费: 否

答案:

Middleware is something that executes between the request and response. In simple words, you can say it acts as a bridge between the request and response. Similarly In Django when a request is made it moves through middlewares to views and data is passed through middleware as a response.

中间件是在请求和响应之间执行的组件。简单来说,你可以说它充当请求和响应之间的桥梁。同样,在 Django 中,当发出请求时,它会经过中间件到达视图,数据也会作为响应通过中间件传递。

703. What is context in the Django?

在Django中,上下文是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72be | 官方: 否 | 付费: 否

答案:

Context is a dictionary mapping template variable name given to Python objects in Django. This is the general name, but you can give any other name of your choice if you want.

上下文是一个字典,用于将模板变量名映射到Django中的Python对象。这是一个通用名称,但如果你愿意,也可以选择任何其他名称。

704. What is django.shortcuts.render function?

什么是django.shortcuts.render函数?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72c1 | 官方: 否 | 付费: 否

答案:

When a view function returns a webpage as HttpResponse instead of a simple string, we use render(). Render function is a shortcut function that lets the developer easily pass the data dictionary with the template. This function then combines the template with a data dictionary via templating engine. Finally, this render() returns as HttpResponse with the rendered text, which is the data returned by models. Thus, Django render() bypasses most of the developer’s work and lets him use different template engines. The basic syntax: render(request, template_name, context=None, content_type=None, status=None, using=None) The request is the parameter that generates the response. The template name is the HTML template used, whereas the context is a dict of the data passed on the page from the python. You can also specify the content type, the status of the data you passed, and the render you are returning.

当视图函数返回网页作为HttpResponse而不是简单字符串时,我们使用render()。Render函数是一个快捷函数,让开发者轻松地将数据字典传递给模板。然后,该函数通过模板引擎将模板与数据字典结合。最后,这个render()返回带有渲染文本的HttpResponse,即模型返回的数据。因此,Django的render()绕过了开发者的大部分工作,使其可以使用不同的模板引擎。基本语法:render(request, template_name, context=None, content_type=None, status=None, using=None)。request是生成响应的参数。模板名称是使用的HTML模板,而context是从Python传递到页面上的数据的字典。你还可以指定内容类型、传递数据的状态以及返回的渲染结果。

705. What’s the significance of the settings.py file?

settings.py文件的重要性是什么?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72c4 | 官方: 否 | 付费: 否

答案:

As the name suggests this file stores the configurations or settings of our Django project, like database configuration, backend engines, middlewares, installed applications, main URL configurations, static file addresses, templating engines, main URL configurations, security keys, allowed hosts, and much more.

正如其名称所示,该文件存储了我们Django项目的配置或设置,如数据库配置、后端引擎、中间件、已安装的应用、主URL配置、静态文件地址、模板引擎、主URL配置、安全密钥、允许的主机等。

706. How to view all items in the Model?

如何查看模型中的所有项目?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72c7 | 官方: 否 | 付费: 否

答案:

ModelName.objects.all()

ModelName.objects.all()

707. How to filter items in the Model?

如何过滤模型中的项目?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72ca | 官方: 否 | 付费: 否

答案:

ModelName.objects.filter(field_name=”term”)

ModelName.objects.filter(field_name=”term”)

708. What's the use of a session framework?

会话框架有什么用途?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72cd | 官方: 否 | 付费: 否

答案:

Using the session framework, you can easily store and retrieve arbitrary data based on the pre-site-visitors. It stores data on the server-side and takes care of the process of sending and receiving cookies. These cookies just consist of a session ID, not the actual data itself unless you explicitly use a cookie-based backend.

使用会话框架,你可以轻松地基于站点访客存储和检索任意数据。它将数据存储在服务器端,并负责发送和接收cookie的过程。这些cookie只包含一个会话ID,而不是实际数据本身,除非你明确使用基于cookie的后端。

709. What are Django Signals?

什么是Django信号?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72d0 | 官方: 否 | 付费: 否

答案:

Whenever there is a modification in a model, we may need to trigger some actions. Django provides an elegant way to handle these in the form of signals. The signals are the utilities that allow us to associate events with actions. We can implement these by developing a function that will run when a signal calls it.

每当模型中有修改时,我们可能需要触发某些操作。Django通过信号提供了一种优雅的方式来处理这些。信号是允许我们将事件与操作关联起来的工具。我们可以通过开发一个在信号调用时运行的函数来实现这些。

List of built-in signals in the models:

模型中内置信号的列表:
Signals
信号
Description
描述
django.db.models.pre_init &django.db.models.post_init
django.db.models.pre_init 和 django.db.models.post_init
Sent before or after a models’s _init_() method is called
在模型的_init_()方法被调用之前或之后发送
django.db.models.signals.pre_save & django.db.models.signals.post_save
django.db.models.signals.pre_save 和 django.db.models.signals.post_save
Sent before or after a model’s save() method is called
在模型的save()方法被调用之前或之后发送
django.db.models.signals.pre_delete &django.db.models.signals.post_delete
django.db.models.signals.pre_delete 和 django.db.models.signals.post_delete
Sent before or after a models’ delete() method or queryset delete() method is called
在模型的delete()方法或查询集的delete()方法被调用之前或之后发送
django.db.models.signals.m2m_changedSent when a ManyToManyField is changed
当ManyToManyField被更改时发送
django.core.signals.request_started &django.core.signals.request_finished
django.core.signals.request_started 和 django.core.signals.request_finished
Sent when an HTTP request is started or finished
当HTTP请求开始或完成时发送

710. Explain the caching strategies in the Django?

解释 Django 中的缓存策略?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72d9 | 官方: 否 | 付费: 否

答案:

Caching refers to the technique of storing the output results when they are processed initially so that next time when the same results are fetched again, instead of processing again those already stored results can be used, which leads to faster accessing as well us less resource utilization. Django provides us with a robust cache system that is able to store dynamic web pages so that these pages don’t need to be evaluated again for each request. Some of the caching strategies in Django are listed below:

缓存是指在首次处理时存储输出结果的技术,这样下次再次获取相同结果时,无需再次处理,可以直接使用已存储的结果,从而实现更快的访问和更少的资源消耗。Django 提供了强大的缓存系统,能够存储动态网页,这样这些页面就不需要为每个请求重新计算。Django 中的一些缓存策略如下所列:
Strategy
策略
Description
描述
MemcachedA memory-based cache server is the fastest and most efficient
基于内存的缓存服务器是最快且最高效的
FileSystem Caching
文件系统缓存
Values of the cache are stored as separate files in a serialized order
缓存的值以序列化顺序存储为独立文件
Local-memory Caching
本地内存缓存
This is used as the default cache strategy by Django if you haven’t set anything. It is per-process as well as thread-safe.
如果你未设置任何内容,Django 会将其用作默认缓存策略。它是每进程且线程安全的。
Database Caching
数据库缓存
Cache data will be stored in the database and works very well if you have a fast and well-indexed DB server.
缓存数据存储在数据库中,如果你有快速且索引良好的数据库服务器,则效果很好。

711. Explain user authentication in Django?

解释 Django 中的用户认证?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72de | 官方: 否 | 付费: 否

答案:

Django comes with a built-in user authentication system, which handles objects like users, groups, user-permissions, and few cookie-based user sessions. Django User authentication not only authenticates the user but also authorizes him. The system consists and operates on these objects: - Users

Django 带有内置的用户认证系统,它处理诸如用户、组、用户权限以及少量基于 cookie 的用户会话等对象。Django 用户认证不仅认证用户,还对其进行授权。该系统由以下对象组成并操作:- 用户
  • Permissions
  • Groups
  • Password Hashing System
  • Forms Validation
  • A pluggable backend system

712. How to configure static files?

如何配置静态文件?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72e1 | 官方: 否 | 付费: 否

答案:

Ensure that django.contrib.staticfiles is added to your INSTALLED_APPS

确保 django.contrib.staticfiles 已添加到你的 INSTALLED_APPS 中

In your settings file. define STATIC_URL for ex.

在你的设置文件中,定义 STATIC_URL,例如

STATIC_URL = '/static/'

STATIC_URL = '/static/'
In your Django templates, use the static template tag to create the URL for the given relative path using the configured STATICFILES_STORAGE.
在你的 Django 模板中,使用 static 模板标签,通过配置的 STATICFILES_STORAGE 为给定的相对路径创建 URL。

{% load static %}

{% load static %}
ABC image
ABC image
Store your static files in a folder called static in your app. For example my_sample/static/my_sample/abcxy.jpg
将你的静态文件存储在应用内名为 static 的文件夹中。例如 my_sample/static/my_sample/abcxy.jpg

713. Explain Django Response lifecycle?

解释 Django 响应生命周期?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72e4 | 官方: 否 | 付费: 否

答案:

Whenever a request is made to a web page, Django creates an HttpRequest object that contains metadata about the request. After that Django loads the particular view, passing the HttpRequest as the first argument to the view function. Each view will be returning an HttpResponse object. On the big picture following steps occur when a request is received by Django:

每当对网页发出请求时,Django 会创建一个包含请求元数据的 HttpRequest 对象。之后,Django 加载特定的视图,将 HttpRequest 作为第一个参数传递给视图函数。每个视图都会返回一个 HttpResponse 对象。从宏观来看,当 Django 收到请求时会发生以下步骤:
  1. First of the Django settings.py file is loaded which also contain various middleware classes (MIDDLEWARES) 2. The middlewares are also executed in the order in which they are mentioned in the MIDDLEWAREST 3. From here on the request is now moved to the URL Router, who simply gets the URL path from the request and tries to map with our given URL paths in the urls.py. 4. As soon as it has mapped, it will call the equivalent view function, from where an equivalent response is generated 5. The response also passes through the response middlewares and send back to the client/browser.

    1. 首先加载 Django 的 settings.py 文件,其中还包含各种中间件类(MIDDLEWARES) 2. 中间件也按照它们在 MIDDLEWARES 中列出的顺序执行 3. 从这里开始,请求被移动到 URL 路由,它从请求中获取 URL 路径,并尝试与 urls.py 中给定的 URL 路径进行映射。 4. 一旦映射成功,它会调用相应的视图函数,从中生成相应的响应 5. 响应也经过响应中间件,然后发送回客户端/浏览器。

714. What databases are supported by Django?

Django支持哪些数据库?
  • 知识点: 后端 / 编程语言基础 (主题: django, python, backend;标签: interviewbit, django, topic-specific, python, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37a7d58d557c902ba72e7 | 官方: 否 | 付费: 否

答案:

PostgreSQL and MySQL, SQLite and Oracle. Apart from these, Django also supports databases such as ODBC, Microsoft SQL Server, IBM DB2, SAP SQL Anywhere, and Firebird using third-party packages. Note: Officially Django doesn’t support any no-SQL databases.

PostgreSQL、MySQL、SQLite和Oracle。除此之外,Django还通过第三方包支持ODBC、Microsoft SQL Server、IBM DB2、SAP SQL Anywhere和Firebird等数据库。注意:Django官方不支持任何NoSQL数据库。

715. 解释 RESTful API(RESTful API)设计的最佳实践,以及在Mavic Series(Mavic Series)中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: dji, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: general
  • 公司: 大疆创新
  • id: 69b37a9c58d557c902ba8617 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

716. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在DoorDash Marketplace中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: doordash, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Doordash
  • id: 69b37aa058d557c902ba8887 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

717. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在Dropbox中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: dropbox, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Dropbox
  • id: 69b37aaf58d557c902ba9027 | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

718. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在Figma Design中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: figma, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Figma
  • id: 69b37af058d557c902bab72f | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

719. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在GitLab CI/CD(Continuous Integration/Continuous Deployment)中有哪些应用场景?

  • 知识点: 后端 / DevOps/云 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: gitlab, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: GitLab
  • id: 69b37b0b58d557c902bac7be | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

720. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在HarmonyOS中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: huawei, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Huawei
  • id: 69b37b4058d557c902bae63c | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

721. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在HubSpot CRM(Customer Relationship Management)中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: hubspot, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: HubSpot
  • id: 69b37b5458d557c902baf131 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

722. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在Instacart Marketplace中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: instacart, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Instacart
  • id: 69b37b6358d557c902baf9ce | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

723. 解释 RESTful API(Representational State Transfer API)设计的最佳实践,以及在Facebook中如何应用。

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: api-design, system-design;标签: meta, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Meta
  • id: 69b37bca58d557c902bb473f | 官方: 是 | 付费: 是

答案:

思路分析从 HTTP(HyperText Transfer Protocol)方法语义、URL(Uniform Resource Locator)设计、版本控制、错误处理、安全性等方面展开。
参考答案核心原则:资源导向 URL、正确使用 HTTP 方法、合理的状态码、分页排序过滤、HATEOAS(Hypermedia As The Engine Of Application State)、版本管理(URL/Header)、认证授权(OAuth2/JWT)。
评分要点- RESTful 设计原则理解

  • 实际项目中的应用经验
  • API 安全性考虑
    常见追问- REST vs GraphQL 的选择?
  • 如何处理 API 向后兼容?

724. 什么是事件驱动架构(EDA,Event-Driven Architecture)?在NAB App中有哪些应用场景?

  • 知识点: 后端 / 系统设计/架构 / UI/UX 设计 (主题: system-design, microservices;标签: nab, generated)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • 公司: Nab
  • id: 69b37bf758d557c902bb6092 | 官方: 是 | 付费: 是

答案:

思路分析从事件生产者(Event Producer)、消费者(Consumer)、事件总线(Event Bus)/消息中间件(Message Broker)的角度解释架构。
参考答案核心概念:事件(Event)作为一等公民,松耦合(Loosely Coupled)的生产者-消费者模型(Producer-Consumer Model)。常见模式:事件通知(Event Notification)、事件溯源(Event Sourcing)、CQRS(Command Query Responsibility Segregation)。消息中间件(Message Broker):Kafka、RabbitMQ。
评分要点- EDA(Event-Driven Architecture)架构模式理解

  • 事件溯源和 CQRS
  • 实际应用经验
    常见追问- 如何处理事件的幂等性(Idempotency)?
  • 事件 schema 如何演进?

725. What is the meaning of a final method and a final class?

final方法和final类的含义是什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74dc | 官方: 否 | 付费: 否

答案:

The final keyword in a declaration of the method indicates that the method cannot be overridden by subclasses. A class that is declared as final cannot be subclassed.

声明方法时的final关键字表示该方法不能被子类重写。声明为final的类不能被继承。

This is especially useful when we are creating an immutable class like the String class. Only classes and methods may be declared final, properties cannot be declared as final.

这在创建像String类这样的不可变类时尤其有用。只有类和类的方法可以声明为final,属性不能声明为final。

726. Explain Path Traversal

解释路径遍历
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74df | 官方: 否 | 付费: 否

答案:

Path traversal is a form of attack to read into the files of a web application . '../' (dot-dot-sequences) is a cross-platform symbol to go up in the directory. Path traversal makes use of this symbol to operate the web application file. The attacker can reveal the content of the file attacked using the path traversal outside the root directory of a web server or application. It is usually done to gain access to secret passwords, tokens, and other sensitive information stored in the files.

路径遍历是一种读取Web应用程序文件的攻击形式。'../'(点-点-序列)是用于在目录中向上移动的跨平台符号。路径遍历利用此符号来操作Web应用程序文件。攻击者可以通过路径遍历在Web服务器或应用程序的根目录之外,揭示被攻击文件的内容。这通常是为了获取存储在文件中的秘密密码、令牌和其他敏感信息。

Path Traversal is also called “Directory Traversal”. It allows the attacker to exploit vulnerabilities present in the web file under attack.

路径遍历也被称为“目录遍历”。它允许攻击者利用被攻击的Web文件中存在的漏洞。

Let’s take a simple example. Consider we have a “Show File” button that opens up some URL.

让我们来看一个简单示例。假设我们有一个能打开某个URL的“显示文件”按钮。

For a classic directory traversal attack, the attacker may try to access the system file /etc/passwd (assuming a UNIX/LINUX system). If the application receives the value of the file parameter from the URL and passes it to a system call, it would traverse the relative path ../../etc/passwd starting from /var/www and ask the system to load the password file.

对于经典的目录遍历攻击,攻击者可能会尝试访问系统文件/etc/passwd(假设是UNIX/LINUX系统)。如果应用程序从URL接收文件参数的值并将其传递给系统调用,它将从/var/www开始遍历相对路径../../etc/passwd,并请求系统加载密码文件。

This technique is also called a dot-dot-slash attack , because it usually uses the special characters ../ (or .. on Windows) to climb to a higher-level directory.

这种技术也称为点-点-斜杠攻击,因为它通常使用特殊字符../(在Windows上为..)来爬升到更高级别的目录。

727. What is the meaning of ‘escaping to PHP’?

“转义到PHP”是什么意思?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74e2 | 官方: 否 | 付费: 否

答案:

The PHP parsing engine needs a way to differentiate PHP code from other page elements. The mechanism to achieve this is known as ‘escaping to PHP’. Escaping a string means reducing ambiguity in quotes used in that string.

PHP解析引擎需要一种方法来区分PHP代码和其他页面元素。实现这一目的的机制被称为“转义到PHP”。转义字符串意味着减少该字符串中使用的引号的歧义。

For example, when you’re defining a string, you surround it in either double quotes or single quotes: "Hello, InterviewBit."

例如,当定义字符串时,你会用双引号或单引号将其包围:"Hello, InterviewBit."

But what if I include double quotes within the string? "Hello "InterviewBit.""

但如果我在字符串中包含双引号呢?"Hello "InterviewBit.""

Now I have ambiguity - the interpreter doesn’t know where does my string end. If I want to keep my double quotes, I have various options. I could use single quotes around my string: 'Hello "InterviewBit."'

现在我有了歧义——解释器不知道我的字符串在哪里结束。如果我想保留双引号,我有多种选择。我可以在字符串周围使用单引号:'Hello "InterviewBit."'

Or I can escape my quotes: "Hello \"InterviewBit.\""

或者我也可以转义我的引号:"Hello \"InterviewBit.\""

Any quote that is preceded by a slash is escaped and understood to be part of the value of the string.

任何前面有斜杠的引号都会被转义,并被理解为字符串值的一部分。

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

728. What is the difference between ASP.NET and PHP?

ASP.NET 和 PHP 有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74e5 | 官方: 否 | 付费: 否

答案:

The main difference between ASP.NET and PHP are given below:

ASP.NET 和 PHP 之间的主要区别如下:
ASP.NETPHP
A web application framework.
一种 Web 应用程序框架。
A server-side scripting language.
一种服务器端脚本语言。
It is designed for use on Windows.
它设计用于 Windows。
It is Platform independent
它是平台无关的
Code is compiled and executed.
代码经过编译然后执行。
Interpreted mode of execution.
解释模式执行。
It has a license cost associated with it.
它带有相关许可费用。
PHP is open-source and freely available.
PHP 是开源且免费提供的。

729. What is the difference between the include() and require() functions?

include() 和 require() 函数有什么区别?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74e8 | 官方: 否 | 付费: 否

答案:

include() function

include() 函数

This function is used to copy all the contents of a file called within the function, text wise into a file from which it is called.

该函数用于将调用函数时指定的文件中的所有内容,以文本形式复制到调用它的文件中。

When the file is included cannot be found, it will only produce a warning (E_WARNING) and the script will continue the execution.

当无法找到包含的文件时,它只会产生一个警告(E_WARNING),脚本将继续执行。

require() function:

require() 函数:

The require() function performs same as the include() function. It also takes the file that is required and copies the whole code into the file from where the require() function is called.

require() 函数执行与 include() 函数相同的操作。它也获取所需的文件,并将整个代码复制到调用 require() 函数的文件中。

When the file is included cannot be found, it will produce a fatal error (E_COMPILE_ERROR) and terminates the script.

当无法找到包含的文件时,它会产生一个致命错误(E_COMPILE_ERROR)并终止脚本。

730. What is the most used method for hashing passwords in PHP?

在 PHP 中,最常用的密码哈希方法是什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74eb | 官方: 否 | 付费: 否

答案:

The crypt() function is used for this functionality as it provides a large number of hashing algorithms that can be used. These algorithms include sha1, sha256, or md5 which are designed to be very fast and efficient.

crypt() 函数用于此功能,因为它提供了大量可用的哈希算法。这些算法包括 sha1、sha256 或 md5,它们被设计得非常快速高效。

731. How does the ‘foreach’ loop work in PHP?

PHP 中的 'foreach' 循环是如何工作的?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74ee | 官方: 否 | 付费: 否

答案:

The foreach statement is a looping construct that is used in PHP to iterate and loop through the array data type.

foreach 语句是一种循环结构,在 PHP 中用于遍历数组数据类型。

The working of foreach is simple, with every single pass of the value, elements get assigned a value, and pointers are incremented. This process is repeatedly done until the end of the array has been reached.

foreach 的工作原理很简单,每次传递值时,元素都会被赋予一个值,并且指针会递增。这一过程会重复进行,直到到达数组末尾。

The syntax for using the foreach statement in PHP is given below:

在 PHP 中使用 foreach 语句的语法如下:

foreach($array as $value)

foreach($array as $value)
{
Code inside the loop;
循环内的代码;
}

732. Does JavaScript interact with PHP?

JavaScript 与 PHP 之间有交互吗?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74f1 | 官方: 否 | 付费: 否

答案:

JavaScript is a client-side programming language, whereas PHP is a server-side scripting language. PHP has the ability to generate JavaScript variables, and this can be executed easily in the browser. Thereby making it possible to pass variables to PHP using a simple URL.

JavaScript 是一种客户端编程语言,而 PHP 是一种服务器端脚本语言。PHP 能够生成 JavaScript 变量,并且这些变量可以在浏览器中轻松执行。因此,通过简单的 URL 就可以将变量传递给 PHP。

733. What are traits?

什么是 traits(特征)?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74f4 | 官方: 否 | 付费: 否

答案:

Traits are a mechanism that lets you create reusable code in PHP and similar languages where multiple inheritances are not supported. It’s not possible to instantiate it on its own.

Traits 是一种机制,允许你在不支持多重继承的 PHP 及类似语言中创建可重用代码。它不能单独实例化。

A trait is intended to reduce the limitations of single inheritance by enabling a developer to reuse sets of methods freely in many independent classes living in different hierarchies of class.

Trait 旨在通过允许开发者在不同类层次结构中许多独立类里自由重用一组方法,来减少单一继承的限制。

734. Explain the main types of errors.

解释主要的错误类型。
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74f7 | 官方: 否 | 付费: 否

答案:

The 3 main types of errors in PHP are: - Notices: Notices are non-critical errors that can occur during the execution of the script. These are not visible to users. Example: Accessing an undefined variable.

PHP 中主要的 3 种错误类型是: - 通知(Notices):通知是在脚本执行过程中可能发生的非关键错误。这些错误对用户不可见。例如:访问未定义的变量。
  • Warnings: These are more critical than notices. Warnings don’t interrupt the script execution. By default, these are visible to the user. Example: include() a file that doesn’t exist.
  • Fatal: This is the most critical error type which, when occurs, immediately terminates the execution of the script. Example: Accessing a property of a non-existent object or require() a non-existent file.

735. Explain the importance of Parser in PHP?

解释 Parser(解析器)在 PHP 中的重要性?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb74fa | 官方: 否 | 付费: 否

答案:

A PHP parser is software that converts source code into the code that computer can understand. This means whatever set of instructions we give in the form of PHP code is converted into a machine-readable format by the parser.

PHP 解析器是将源代码转换为计算机能理解的代码的软件。这意味着我们以 PHP 代码形式提供的任何指令集都会被解析器转换成机器可读的格式。

You can parse PHP code with PHP using the token_get_all() function.

你可以使用 PHP 的 token_get_all() 函数来解析 PHP 代码。

736. How can PHP and HTML interact?

PHP 和 HTML 如何交互?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb7501 | 官方: 否 | 付费: 否

答案:

PHP scripts have the ability to generate HTML, and it is possible to pass information from HTML to PHP.

PHP 脚本能够生成 HTML,并且可以将信息从 HTML 传递到 PHP。

PHP is a server-side language whereas HTML is a client-side language. So PHP executes on the server-side and gets its results as strings, objects, arrays, and then we use them to display its values in HTML.

PHP 是服务器端语言,而 HTML 是客户端语言。因此,PHP 在服务器端执行,并将结果作为字符串、对象、数组等获取,然后我们使用这些结果在 HTML 中显示其值。

This interaction helps bridge the gaps and use the best of both languages.

这种交互有助于弥合差距,并发挥两种语言的优势。

737. What is the purpose of @ in PHP?

PHP 中 @ 的用途是什么?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb7504 | 官方: 否 | 付费: 否

答案:

In PHP, @ is used for suppressing error messages. If any runtime error occurs on the line which consists @ symbol at the beginning, then the error will be handled by PHP.

在 PHP 中,@ 用于抑制错误消息。如果以 @ 符号开头的行上发生任何运行时错误,则该错误将由 PHP 处理。

738. What are the different types of Array in PHP?

PHP 中有哪些不同类型的数组?
  • 知识点: 后端 / 编程语言基础 (主题: php, backend;标签: interviewbit, php, topic-specific, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c1958d557c902bb7507 | 官方: 否 | 付费: 否

答案:

There are 3 main types of arrays that are used in PHP:

在 PHP 中使用的数组主要有 3 种类型:

Types of Arrays in PHP

PHP 中的数组类型

Indexed Array

索引数组

An array with a numeric key is known as the indexed array. Values are stored and accessed in linear order.

带有数字键的数组称为索引数组。值以线性顺序存储和访问。

Indexed Array

索引数组

Associative Array

关联数组

An array with strings for indexing elements is known as the associative array. Element values are stored in association with key values rather than in strict linear index order.

使用字符串索引元素的数组称为关联数组。元素值以与键值关联的方式存储,而不是严格按照线性索引顺序存储。

Associative Array

关联数组

Multidimensional Array

多维数组

An array containing one or more arrays within itself is known as a multidimensional array. The values are accessed using multiple indices.

包含一个或多个数组的数组称为多维数组。值使用多个索引进行访问。

Multidimensional Array

多维数组

739. How can the JAX-RS applications be configured?

如何配置JAX-RS应用程序?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6608 | 官方: 否 | 付费: 否

答案:

JAX-RS applications have the root resource classes packaged in a war file. There are 2 means of configuring JAX-RS applications.

JAX-RS应用程序将根资源类打包在war文件中。配置JAX-RS应用程序有两种方式。
  1. Use @ApplicationPath annotation in a subclass of javax.ws.rs.core.Application that is packaged in the WAR file. 2. Use the tag inside the web.xml of the WAR. web.xml is the deployment descriptor of the application where the mappings to the servlets can be defined.

    1. 在打包于WAR文件中的javax.ws.rs.core.Application子类上使用@ApplicationPath注解。 2. 在WAR的web.xml中使用标签。web.xml是应用程序的部署描述符,可以在其中定义到servlet的映射。

740. What do you understand by request method designator annotations?

你对请求方法指示器注解的理解是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc661a | 官方: 否 | 付费: 否

答案:

They are the runtime annotations in the JAX-RS library that are applied to Java methods. They correspond to the HTTP request methods that the clients want to make. They are @GET, @POST, @PUT, @DELETE, @HEAD.

它们是JAX-RS库中的运行时注解,应用于Java方法。它们对应于客户端想要发出的HTTP请求方法。它们包括@GET、@POST、@PUT、@DELETE、@HEAD。

Usage Example:

使用示例:

import javax.ws.rs.Path;

import javax.ws.rs.Path;
/**
  • InterviewBitService is a root resource class that is exposed at 'resource_service' path

    • InterviewBitService 是一个根资源类,在 'resource_service' 路径下暴露
      */
      @Path('resource_service')
      @Path('resource_service')
      public class InterviewBitService {
      public class InterviewBitService {
      @GET
      @GET
      public String getRESTQuestions() {
      public String getRESTQuestions() {
      // some operations
      // 一些操作
      }
      }

741. Is it possible to make asynchronous requests in JAX-RS?

在JAX-RS中是否可以发起异步请求?
  • 知识点: 后端 / 行为与软技能 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: behavioral | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc661d | 官方: 否 | 付费: 否

答案:

Yes. the JAX-RS Client API provides a method called Invocation.Builder.async() that is used for constructing client requests that need to be executed asynchronously. Invoking a request asynchronously does the task of returning the control to the caller by returning with datatype java.util.concurrent.Future whose type is set to return the service call type. Future objects are used because they have the required methods to check whether the asynchronous calls have been completed and if yes, then retrieve the responses. They also provide the flexibility to cancel the request invocations and also check if the cancellation has been successful.

可以。JAX-RS客户端API提供了一种名为Invocation.Builder.async()的方法,用于构建需要异步执行的客户端请求。异步调用请求会通过返回java.util.concurrent.Future数据类型(其类型设置为返回服务调用类型)将控制权返回给调用者。使用Future对象是因为它们具有检查异步调用是否已完成以及如果完成则检索响应所需的方法。它们还提供了取消请求调用以及检查取消是否成功的灵活性。

Let us understand this with the help of a random example. We know that the Future interface from the java.util.concurrent has the below functions available:

让我们通过一个随机示例来理解这一点。我们知道来自java.util.concurrent的Future接口具有以下可用函数:

package java.util.concurrent;

package java.util.concurrent;
public interface Future {
public interface Future {
// informs the executor to stop the thread execution
// 通知执行器停止线程执行
boolean cancel(boolean mayInterruptIfRunning);
boolean cancel(boolean mayInterruptIfRunning);

// indicates whether the Future was cancelled or not

// 指示 Future 是否已被取消
boolean isCancelled();
boolean isCancelled();

// indicates if the executor has completed the task

// 指示执行器是否已完成任务
boolean isDone();
boolean isDone();

// gets the actual result from the process.

// 从进程中获取实际结果。
// This blocks the program execution until the result is ready.
// 这会阻塞程序执行,直到结果准备好。
V get() throws InterruptedException, ExecutionException;
V get() throws InterruptedException, ExecutionException;

// also gets actual result from the process but it throws

// 也从进程中获取实际结果,但如果未在指定超时前获得结果,
// the TimeoutException in case the result is not obtained before specified timeout
// 则会抛出 TimeoutException
V get(long timeout, TimeUnit unit)
V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException;
throws InterruptedException, ExecutionException, TimeoutException;
}
Let us consider we have this function below which is used for processing 2 Ids parallelly.
让我们考虑下面这个函数,它用于并行处理 2 个 Id。

public void processIds(String userId1, String questionId){

public void processIds(String userId1, String questionId){
Client client = ClientBuilder.newClient();
Client client = ClientBuilder.newClient();
Future futureResponse1 = client.target("http://interviewbitserver.com/users/"+userId).request().async().get();
Future futureResponse1 = client.target("http://interviewbitserver.com/users/"+userId).request().async().get();
Future futureResponse2 = client.target("http://interviewbitserver.com/questions/"+questionId).request().async().get(Question.class);
Future futureResponse2 = client.target("http://interviewbitserver.com/questions/"+questionId).request().async().get(Question.class);

// block the process until complete

// 阻塞进程直到完成
Response response1 = futureResponse1.get();
Response response1 = futureResponse1.get();
User userObject = response1.readEntity(User.class);
User userObject = response1.readEntity(User.class);
//Do processing of userObject
//对userObject进行处理

// Wait for 2 seconds before fetching record

// 在获取记录前等待2秒
try {
try {
Question question = futureResponse2.get(2, TimeUnit.SECONDS);
Question question = futureResponse2.get(2, TimeUnit.SECONDS);
//Do Processing of question
//对question进行处理
} catch (TimeoutException timeoutException ) {
} catch (TimeoutException timeoutException ) {
//handle exceptions
//处理异常
}
return;
return;
}
In the above example, we see that there are 2 separate requests getting executed parallelly. For the first future object, we await the javax.ws.rs.core.Response indefinitely using the get() method until we get the response. For the second future object, we wait for the response only for 2 seconds and if we do not get within 2 seconds, then the get() method throws TimeoutException. We can also use the isDone() method or isCancelled() method to find out whether the executors have completed or cancelled.
在上述示例中,我们看到有2个独立的请求并行执行。对于第一个future对象,我们使用get()方法无限期地等待javax.ws.rs.core.Response,直到收到响应。对于第二个future对象,我们仅等待响应2秒,如果在2秒内未收到,则get()方法会抛出TimeoutException。我们还可以使用isDone()方法或isCancelled()方法来检查执行器是否已完成或已取消。

742. List the key annotations that are present in the JAX-RS API?

列出JAX-RS API中存在的关键注解?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6622 | 官方: 否 | 付费: 否

答案:

  • @Path - This specifies the relative URI path to the REST resource.
  • @GET - This is a request method designator which is corresponding to the HTTP GET requests. They process GET requests.
  • @POST - This is a request method designator which is corresponding to the HTTP POST requests. They process POST requests.
  • @PUT - This is a request method designator which is corresponding to the HTTP PUT requests. They process PUT requests.
  • @DELETE - This is a request method designator which is corresponding to the HTTP DELETE requests. They process DELETE requests.
  • @HEAD - This is a request method designator which is corresponding to the HTTP HEAD requests. They process HEAD requests.
  • @PathParam - This is the URI path parameter that helps developers to extract the parameters from the URI and use them in the resource class/methods.
  • @QueryParam - This is the URI query parameter that helps developers extract the query parameters from the URI and use them in the resource class/methods.
  • @Produces - This specifies what MIME media types of the resource representations are produced and sent to the client as a response.
  • @Consumes - This specifies which MIME media types of the resource representations are accepted or consumed by the server from the client.

743. Define RESTful Root Resource Classes in the JAX-RS API?

在JAX-RS API中定义RESTful根资源类?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc662c | 官方: 否 | 付费: 否

答案:

  • A resource class is nothing but a Java class that uses JAX-RS provided annotations for implementing web resources.
  • They are the POJOs that are annotated either with @Path or have at least one method annotated with @Path, @GET, @POST, @DELETE, @PUT, etc.

Example:

示例:
import javax.ws.rs.Path;
import javax.ws.rs.Path;
/**
  • InterviewBitService is a root resource class that is exposed at 'resource_service' path

    • InterviewBitService 是一个根资源类,在 'resource_service' 路径下暴露
      */
      @Path('resource_service')
      @Path('resource_service')
      public class InterviewBitService {
      public class InterviewBitService {
      // Defined methods
      // 已定义的方法
      }

744. What are the key features provided by JAX-RS API in Java EE?

JAX-RS API 在 Java EE 中提供了哪些关键特性?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc662f | 官方: 否 | 付费: 否

答案:

JAX-RS stands for Java API for RESTful Web services. They are nothing but a set of Java-based APIs that are provided in the Java EE which is useful in the implementation and development of RESTful web services.

JAX-RS 代表 Java API for RESTful Web services(用于 RESTful Web 服务的 Java API)。它们只是 Java EE 中提供的一组基于 Java 的 API,可用于实现和开发 RESTful Web 服务。

Features of JAX-RS are: - POJO-based: The APIs in the JAX-RS is based on a certain set of annotations, classes, and interfaces that are used with POJO (Plain Old Java Object) to expose the services as web services.

JAX-RS 的特性包括: - 基于 POJO:JAX-RS 中的 API 基于一组特定的注解、类和接口,它们与 POJO(普通 Java 对象)一起使用,以将服务暴露为 Web 服务。
  • HTTP-based: The JAX-RS APIs are designed using HTTP as their base protocol. They support the HTTP usage patterns and they provide the corresponding mapping between the HTTP actions and the API classes.
  • Format Independent: They can be used to work with a wide range of data types that are supported by the HTTP body content.
  • Container Independent: The APIs can be deployed in the Java EE container or a servlet container such as Tomcat or they can also be plugged into JAX-WS (Java API for XML-based web services) providers.

745. Define RestTemplate in Spring.

在 Spring 中定义 RestTemplate。
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6632 | 官方: 否 | 付费: 否

答案:

The RestTemplate is the main class meant for the client-side access for Spring-based RESTful services. The communication to the server is accomplished using the REST constraints. This is similar to other template classes such as JdbcTemplate, HibernateTemplate, etc provided by Spring. The RestTemplate provides high-level implementation details for the HTTP Methods like GET, POST, PUT, etc, and gives the methods to communicate using the URI template, URI path params, request/response types, request object, etc as part of arguments. - Commonly used annotations like @GetMapping, @PostMapping, @PutMapping, etc are provided by this class from Spring 4.3. Prior to that, Spring provided (and still provides) @RequestMapping annotation to indicate what methods were being used.

RestTemplate 是用于基于 Spring 的 RESTful 服务的客户端访问的主类。与服务器的通信是通过 REST 约束完成的。这与 Spring 提供的其他模板类(如 JdbcTemplate、HibernateTemplate 等)类似。RestTemplate 为 HTTP 方法(如 GET、POST、PUT 等)提供了高级实现细节,并提供使用 URI 模板、URI 路径参数、请求/响应类型、请求对象等作为参数进行通信的方法。 - 此类从 Spring 4.3 起提供了常用的注解,如 @GetMapping、@PostMapping、@PutMapping 等。在此之前,Spring 提供了(并且仍然提供)@RequestMapping 注解来指示使用了哪些方法。

746. What is the use of @RequestMapping?

@RequestMapping 的用途是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6635 | 官方: 否 | 付费: 否

答案:

  • The annotation is used for mapping requests to specific handler classes or methods.
  • In spring, all the incoming web request routing is handled by Dispatcher Servlet. When it gets the request, it determines which controller is meant for processing the request by means of request handlers. The Dispatcher Servlet scans all the classes annotated with @Controller. The process of routing requests depends on @RequestMapping annotations that are declared inside the controller classes and their methods.

747. What are the differences between the annotations @Controller and @RestController?

注解 @Controller 和 @RestController 之间的区别是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6638 | 官方: 否 | 付费: 否

答案:

@Controller@RestController
Mostly used traditional Spring MVC service.
主要用于传统 Spring MVC 服务。
Represents RESTful web service in Spring.
在 Spring 中表示 RESTful Web 服务。
It is mostly used in Spring MVC service where model data needs to rendered using view.
主要用于需要将模型数据通过视图渲染的 Spring MVC 服务。
It is used in case of RESTful web service that returns object values bound to response body.
用于返回绑定到响应体的对象值的 RESTful Web 服务。
If response values need to be converted through HttpMessageConverters and sent via response object, extra annotation @ResponseBody needs to be used on the class or the method handlers.
如果响应值需要通过 HttpMessageConverters 转换并通过响应对象发送,则需要在类或方法处理器上使用额外的注解 @ResponseBody。
The default behavior of the @RestController needs to be written on the response body because it is the combination of @Controller and @ResponseBody.
@RestController 的默认行为是将内容写入响应体,因为它是 @Controller 和 @ResponseBody 的组合。
@Controller provides control and flexibility over how the response needs to be sent.
@Controller 对应答的发送方式提供了控制和灵活性。
@RestController annotation has no such flexibility and writes all the results to the response body.
@RestController 注解没有这种灵活性,它会将所有结果写入响应体。

748. What does the annotation @PathVariable do?

注解 @PathVariable 的作用是什么?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc663b | 官方: 否 | 付费: 否

答案:

@PathVariable annotation is used for passing the parameter with the URL that is required to get the data. Spring MVC provides support for URL customization for data retrieval using @PathVariable annotation.

@PathVariable 注解用于将获取数据所需的参数与 URL 一起传递。Spring MVC 通过 @PathVariable 注解为数据检索提供 URL 自定义支持。

749. Is it necessary to keep Spring MVC in the classpath for developing RESTful web services?

开发 RESTful Web 服务时,是否必须将 Spring MVC 保留在 classpath 中?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc663e | 官方: 否 | 付费: 否

答案:

Yes. Spring MVC needs to be on the classpath of the application while developing RESTful web services using Spring. This is because, the Spring MVC provides the necessary annotations like @RestController, @RequestBody, @PathVariable, etc. Hence the spring-mvc.jar needs to be on the classpath or the corresponding Maven entry in the pom.xml.

是的。在使用Spring开发RESTful Web服务时,Spring MVC需要位于应用程序的类路径中。这是因为Spring MVC提供了诸如@RestController、@RequestBody、@PathVariable等必要的注解。因此,spring-mvc.jar需要位于类路径中,或者在pom.xml中有相应的Maven条目。

750. Define HttpMessageConverter in terms of Spring REST?

用Spring REST术语定义HttpMessageConverter?
  • 知识点: 后端 (主题: rest, api, backend;标签: interviewbit, rest-api, topic-specific, rest, api, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3658d557c902bc6641 | 官方: 否 | 付费: 否

答案:

HttpMessageConverter is a strategic interface that specified a converter for conversion between HTTP Requests and responses. Spring REST uses the HttpMessageConverter for converting responses to various data formats like JSON, XML, etc. Spring makes use of the “Accept” header for determining the type of content the client expects. Based on this, Spring would find the registered message converter interface that is capable of this conversion.

HttpMessageConverter是一个战略接口,它指定了一个用于HTTP请求和响应之间转换的转换器。Spring REST使用HttpMessageConverter将响应转换为各种数据格式,如JSON、XML等。Spring利用“Accept”头部来确定客户端期望的内容类型。基于此,Spring会查找能够执行此转换的已注册消息转换器接口。

751. What is the problem with the following controller code? How would you fix it?

以下控制器代码有什么问题?你如何修复它?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6750 | 官方: 否 | 付费: 否

答案:

class MyController < ApplicationController

class MyController < ApplicationController
def options
def options
options = {}
options = {}
available_option_keys = [:first_option, :second_option, :third_option]
available_option_keys = [:first_option, :second_option, :third_option]
all_keys = params.keys.map(&:to_sym)
all_keys = params.keys.map(&:to_sym)
set_option_keys = all_keys & available_option_keys
set_option_keys = all_keys & available_option_keys
set_option_keys.each do |key|
set_option_keys.each do |key|
options[key] = params[key]
options[key] = params[key]
end
end
options
options
end
end
end
end
Converting user-supplied arguments to symbols is risky since symbols in Ruby are not garbage collected. An attacker may submit a series of requests containing random keys that would be converted to symbols, quickly draining your server's memory and bringing your site down.
将用户提供的参数转换为符号是有风险的,因为Ruby中的符号不会被垃圾回收。攻击者可能提交一系列包含随机键的请求,这些键会被转换为符号,迅速消耗服务器内存,导致网站宕机。

There are two possible solutions to this problem. The first is to use a slice to filter out non-option-key values from the params hash. This would seem as follows:

解决这个问题有两种可能的方案。第一种是使用slice从params哈希中过滤出非选项键的值。这看起来如下所示:

params.slice(*available option keys)

params.slice(*available option keys)
Using String keys for your selections is an alternate, and some would argue a better solution. Unless you have a very high number of viable choice keys, using Symbol keys instead will not save you any memory.
为你的选择使用字符串键是另一种方案,一些人认为这是更好的方案。除非你有非常多的可行选择键,否则使用符号键不会节省任何内存。

752. Write a function in Ruby to check if the string is a palindrome.

编写一个Ruby函数来检查字符串是否为回文。
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6753 | 官方: 否 | 付费: 否

答案:

def palindrome?(str)

def palindrome?(str)
str == str.reverse
str == str.reverse
end
end

753. What will be the output of the given code snippet?

给定代码片段的输出将是什么?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: coding
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6756 | 官方: 否 | 付费: 否

答案:

x, y, z = 12, 36, 72

x, y, z = 12, 36, 72
puts "The value of x is #{ x }."
puts "The value of x is #{ x }."
puts "The sum of x and y is #{ x + y }."
puts "The sum of x and y is #{ x + y }."
puts "The average was #{ (x + y + z)/3 }."
puts "The average was #{ (x + y + z)/3 }."
Output:
输出:

The value of x is 12.

The value of x is 12.
The sum of x and y is 48.
The sum of x and y is 48.
The average was 40.
The average was 40.

754. What paths (HTTP verb and URL) will be defined by the following snippet in config/routes.rb?

在 config/routes.rb 中,以下代码片段将定义哪些路径(HTTP 动词和 URL)?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6759 | 官方: 否 | 付费: 否

答案:

resources :posts do

resources :posts do
member do
member do
get 'comments'
get 'comments'
end
end
collection do
collection do
post 'bulk_upload'
post 'bulk_upload'
end
end
end
end
Using the resource method to define routes will automatically generate routes for the standard seven restful actions: - GET /posts
使用 resource 方法定义路由将自动为标准 RESTful 七个动作生成路由:- GET /posts
  • POST /posts
  • GET /posts/new
  • GET /posts/:id/edit
  • GET /posts/:id
  • PATCH/PUT /posts/:id
  • DELETE /posts/:id

755. Given this input:

给定以下输入:
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc675c | 官方: 否 | 付费: 否

答案:

x = [{"a" => 10},{"b" => 20},{"c" => 30}]

x = [{"a" => 10},{"b" => 20},{"c" => 30}]
How will you obtain the following:
你将如何获得以下内容:
  • One array containing all keys
  • Another containing all values

The code will look something like this:

代码大致如下:
y = x[0].merge(x[1]).merge(x[2])
y = x[0].merge(x[1]).merge(x[2])

y.keys # will return all keys

y.keys # 将返回所有键
y.values # will return all values
y.values # 将返回所有值
Conclusion
结论
The above Ruby on Rails Interview Questions can help you a lot in learning and passing your interviews. The article is for you if you are a fresher looking for a job in Ruby on Rails or an experienced person who wants to better your skills in Ruby on rails. I hope the article serves you well. - Backend Developer Skills
上述Ruby on Rails面试问题可以帮助你极大地学习和通过面试。无论你是寻找Ruby on Rails工作的新手,还是希望提升Ruby on Rails技能的经验丰富者,这篇文章都适合你。我希望这篇文章对你有所助益。- 后端开发技能
  • Top Backend Technologies
  • Top Skills To Become a Full Stack Developer
  • Technical Interview Questions

    FAQ'S

756. What does a Ruby on Rails developer do?

Ruby on Rails开发人员做什么?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc675f | 官方: 否 | 付费: 否

答案:

A Ruby on Rails developer is in charge of building Ruby-based server-side web application logic for the Rails framework. Roles and responsibilities of a Ruby on rails developer include - New web application design and development.

Ruby on Rails开发人员负责构建Rails框架中基于Ruby的服务器端Web应用逻辑。Ruby on Rails开发人员的角色和职责包括- 新Web应用的设计和开发。
  • Existing web apps' maintenance and troubleshooting.
  • Writing and maintaining dependable Ruby code
  • Bringing data storage options together.
  • Back-end component development.
  • Finding and eliminating constraints and bugs.
  • Additional web servers are connected to apps.
  • API management.

757. Is Ruby on Rails in demand?

Ruby on Rails需求量高吗?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6762 | 官方: 否 | 付费: 否

答案:

Ruby on Rails has been around for a long time and has proven reliable. Although its popularity has waned over time, hundreds of developers continue to trust and enjoy working with it.

Ruby on Rails已经存在很长时间,并被证明是可靠的。虽然它的受欢迎程度随时间有所下降,但数百名开发人员仍然信任并喜欢使用它。

758. How much does a Ruby on Rails developer make?

Ruby on Rails开发人员能挣多少钱?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6765 | 官方: 否 | 付费: 否

答案:

According to the ambition box, the average yearly income for a Ruby on Rails Developer in India is 6.5 lakhs, with salaries ranging from 1.9 lakhs to 15.0 lakhs.

根据ambition box的数据,印度Ruby on Rails开发人员的平均年收入为65万卢比,薪资范围从19万卢比到150万卢比不等。

759. Is Ruby on rails good for freelancing?

Ruby on Rails适合自由职业吗?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc6768 | 官方: 否 | 付费: 否

答案:

With all the frameworks and libraries available (such as Rails, Merb and Sintara), Ruby is definitely great for freelancing. Its focus on clean code and object-oriented syntax, and a strong community will also help you a lot in your freelancing career.

凭借所有可用的框架和库(如Rails、Merb和Sintara),Ruby绝对非常适合自由职业。它专注于简洁代码和面向对象语法,以及强大的社区也将极大地帮助你的自由职业事业。

760. What is something you like about working with Rails?

你喜欢使用Rails工作的方面是什么?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc676b | 官方: 否 | 付费: 否

答案:

Ruby on Rails is fantastic because it simplifies basic web development processes, allowing developers to concentrate on their app's functionality. To do simple procedures, you no longer need to create endless database queries.

Ruby on Rails非常出色,因为它简化了基本的Web开发流程,让开发人员能够专注于应用的功能。你不再需要为了简单操作而编写无尽的数据库查询。

761. Is Ruby front end or backend?

Ruby是前端还是后端?
  • 知识点: 后端 / 编程语言基础 (主题: ruby, rails, backend;标签: interviewbit, ruby-on-rails, topic-specific, ruby, rails, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c3858d557c902bc676e | 官方: 否 | 付费: 否

答案:

Ruby On Rails is a front-end and back-end framework. Because Ruby on Rails covers both the frontend and the backend, you may consider yourself a true full-stack developer.

Ruby on Rails是一个前端和后端框架。由于Ruby on Rails涵盖了前端和后端,你可以将自己视为真正的全栈开发人员。

762. What are the bean scopes available in Spring?

Spring中可用的Bean作用域有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79c1 | 官方: 否 | 付费: 否

答案:

The Spring Framework has five scope supports. They are: - Singleton: The scope of bean definition while using this would be a single instance per IoC container.

Spring框架支持五种作用域。它们是:- 单例(Singleton):使用此作用域时,Bean定义在IoC容器中只有一个实例。
  • Prototype: Here, the scope for a single bean definition can be any number of object instances.
  • Request: The scope of the bean definition is an HTTP request.
  • Session: Here, the scope of the bean definition is HTTP-session.
  • Global-session: The scope of the bean definition here is a Global HTTP session.
    Note: The last three scopes are available only if the users use web-aware ApplicationContext containers.

    注意:最后三种作用域仅在用户使用基于Web的ApplicationContext容器时可用。

763. What are the limitations of autowiring?

自动装配有哪些限制?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79c4 | 官方: 否 | 付费: 否

答案:

  • Overriding possibility: Dependencies are specified using and settings that override autowiring.
  • Data types restriction: Primitive data types, Strings, and Classes can’t be autowired.

764. What is autowiring and name the different modes of it?

什么是自动装配,并说出它的不同模式?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79c7 | 官方: 否 | 付费: 否

答案:

The IoC container autowires relationships between the application beans. Spring lets collaborators resolve which bean has to be wired automatically by inspecting the contents of the BeanFactory. Different modes of this process are: - no: This means no autowiring and is the default setting. An explicit bean reference should be used for wiring.

IoC容器自动装配应用程序Bean之间的关系。Spring通过检查BeanFactory的内容,让协作者自动解析哪个Bean需要被装配。此过程的不同模式有:- no:这意味着不进行自动装配,是默认设置。装配时需要使用显式的Bean引用。
  • byName: The bean dependency is injected according to the name of the bean. This matches and wires its properties with the beans defined by the same names as per the configuration.
  • byType: This injects the bean dependency based on type.
  • constructor: Here, it injects the bean dependency by calling the constructor of the class. It has a large number of parameters.
  • autodetect: First the container tries to wire using autowire by the constructor, if it isn't possible then it tries to autowire by byType.

765. What do you understand by Bean Wiring.

你对Bean装配有何理解?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79ca | 官方: 否 | 付费: 否

答案:

  • When beans are combined together within the Spring container, they are said to be wired or the phenomenon is called bean wiring.
  • The Spring container should know what beans are needed and how the beans are dependent on each other while wiring beans. This is given by means of XML / Annotations / Java code-based configuration.

766. Explain Bean life cycle in Spring Bean Factory Container.

解释Spring Bean Factory容器中的Bean生命周期。
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79cd | 官方: 否 | 付费: 否

答案:

The Bean life cycle is as follows: - The IoC container instantiates the bean from the bean’s definition in the XML file.

Bean的生命周期如下:- IoC容器根据XML文件中Bean的定义实例化Bean。
  • Spring then populates all of the properties using the dependency injection as specified in the bean definition.
  • The bean factory container calls setBeanName() which take the bean ID and the corresponding bean has to implement BeanNameAware interface.
  • The factory then calls setBeanFactory() by passing an instance of itself (if BeanFactoryAware interface is implemented in the bean).
  • If BeanPostProcessors is associated with a bean, then the preProcessBeforeInitialization() methods are invoked.
  • If an init-method is specified, then it will be called.
  • Lastly, postProcessAfterInitialization() methods will be called if there are any BeanPostProcessors associated with the bean that needs to be run post creation.
  • Data Science
  • All Events
  • My Events

767. How is the configuration meta data provided to the spring container?

如何向Spring容器提供配置元数据?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79d0 | 官方: 否 | 付费: 否

答案:

There are 3 ways of providing the configuration metadata. They are as follows: - XML-Based configuration: The bean configurations and their dependencies are specified in XML configuration files. This starts with a bean tag as shown below:

有3种提供配置元数据的方式。它们如下:- 基于XML的配置:Bean配置及其依赖关系在XML配置文件中指定。这以如下所示的bean标签开始:




- Annotation-Based configuration: Instead of the XML approach, the beans can be configured into the component class itself by using annotations on the relevant class, method, or field declaration.Annotation wiring is not active in the Spring container by default. This has to be enabled in the Spring XML configuration file as shown below
- 基于注解的配置:与XML方式不同,可以通过在相关类、方法或字段声明上使用注解,将Bean配置到组件类本身中。然而,默认情况下,Spring容器中并未启用注解装配。这需要在Spring的XML配置文件中进行启用,如下所示:


<context:annotation-config/>
<context:annotation-config/>

- Java-based configuration: Spring Framework introduced key features as part of new Java configuration support. This makes use of the @Configuration annotated classes and @Bean annotated methods. Note that:
- 基于Java的配置:Spring框架在新增的Java配置支持中引入了关键特性,这利用了带有@Configuration注解的类和带有@Bean注解的方法。请注意:
@Bean annotation has the same role as the element. Classes annotated with @Configuration allow to define inter-bean dependencies by simply calling other @Bean methods in the same class.
@Bean注解与元素具有相同的作用。带有@Configuration注解的类允许通过简单地在同一类中调用其他@Bean方法来定义Bean之间的依赖关系。

768. What are Spring Beans?

什么是Spring Beans?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79d3 | 官方: 否 | 付费: 否

答案:

  • They are the objects forming the backbone of the user’s application and are managed by the Spring IoC container.
  • Spring beans are instantiated, configured, wired, and managed by IoC container.
  • Beans are created with the configuration metadata that the users supply to the container (by means of XML or java annotations configurations.)

Check out Scaler Topics' Free Java Spring Boot course to master the fundamentals of Java Spring Boot.

查看Scaler Topics的免费Java Spring Boot课程,以掌握Java Spring Boot的基础知识。

769. Explain the difference between constructor and setter injection?

解释构造函数注入和setter注入之间的区别?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79d6 | 官方: 否 | 付费: 否

答案:

  • In constructor injection, partial injection is not allowed whereas it is allowed in setter injection.
  • The constructor injection doesn’t override the setter property whereas the same is not true for setter injection.
  • Constructor injection creates a new instance if any modification is done. The creation of a new instance is not possible in setter injection.
  • In case the bean has many properties, then constructor injection is preferred. If it has few properties, then setter injection is preferred.

770. What do you understand by Dependency Injection?

你如何理解依赖注入?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79d9 | 官方: 否 | 付费: 否

答案:

The main idea in Dependency Injection is that you don’t have to create your objects but you just have to describe how they should be created. - The components and services need not be connected by us in the code directly. We have to describe which services are needed by which components in the configuration file. The IoC container present in Spring will wire them up together.

依赖注入的主要思想是:你不必创建自己的对象,只需描述它们应该如何被创建。组件和服务不需要我们在代码中直接连接。我们必须在配置文件中描述哪些组件需要哪些服务。Spring容器中的IoC容器会将它们连接在一起。
  • In Java, the 2 major ways of achieving dependency injection are:
    Constructor injection: Here, the IoC container invokes the class constructor with a number of arguments where each argument represents a dependency on the other class.

    构造函数注入:在这里,IoC容器调用带有一系列参数的类构造函数,其中每个参数代表对另一个类的依赖。
    Setter injection: Here, the spring container calls the setter methods on the beans after invoking a no-argument static factory method or default constructor to instantiate the bean.
    Setter注入:在这里,Spring容器在调用无参静态工厂方法或默认构造函数来实例化Bean之后,会调用Bean上的setter方法。

771. What do you mean by IoC (Inversion of Control) Container?

你所说的IoC(控制反转)容器是什么意思?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79dc | 官方: 否 | 付费: 否

答案:

Spring container forms the core of the Spring Framework. The Spring container uses Dependency Injection (DI) for managing the application components by creating objects, wiring them together along with configuring and managing their overall life cycles. The instructions for the spring container to do the tasks can be provided either by XML configuration, Java annotations, or Java code.

Spring容器构成了Spring框架的核心。Spring容器使用依赖注入(DI)来管理应用程序组件,通过创建对象、将它们连接在一起,以及配置和管理它们的整个生命周期来实现。关于Spring容器执行这些任务的指令可以通过XML配置、Java注解或Java代码提供。

772. What is a Spring configuration file?

什么是Spring配置文件?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79df | 官方: 否 | 付费: 否

答案:

A Spring configuration file is basically an XML file that mainly contains the classes information and describes how those classes are configured and linked to each other. The XML configuration files are verbose and cleaner.

Spring配置文件基本上是一个XML文件,主要包含类信息,并描述这些类如何被配置和相互关联。XML配置文件详细且更清晰。

773. What are the features of Spring Framework?

Spring框架有哪些特性?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79e2 | 官方: 否 | 付费: 否

答案:

  • Spring framework follows layered architecture pattern that helps in the necessary components selection along with providing a robust and cohesive framework for J2EE applications development.
  • The AOP (Aspect Oriented Programming) part of Spring supports unified development by ensuring separation of application’s business logic from other system services.
  • Spring provides highly configurable MVC web application framework which has the ability to switch to other frameworks easily.
  • Provides provision of creation and management of the configurations and defining the lifecycle of application objects.
  • Spring has a special design principle which is known as IoC (Inversion of Control) that supports objects to give their dependencies rather than looking for creating dependent objects.
  • Spring is a lightweight, java based, loosely coupled framework.
  • Spring provides generic abstraction layer for transaction management that is also very useful for container-less environments.
  • Spring provides a convenient API to translate technology-specific exceptions (thrown by JDBC, Hibernate or other frameworks) into consistent, unchecked exceptions. This introduces abstraction and greatly simplifies exception handling.

Successful Tech Career for FREE!

免费开启成功的科技职业生涯!

Successful Tech Career!

成功的技术职业生涯!

Interview Process

面试流程

CTC & Designation

CTC与职位级别

Projects on the Job

工作项目

Referral System

推荐系统

Try It Out

试试看

2 Lakh+ Roadmaps Created

已生成20万+职业规划

774. What is Spring Framework?

什么是Spring框架?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79e5 | 官方: 否 | 付费: 否

答案:

  • Spring is a powerful open-source, loosely coupled, lightweight, java framework meant for reducing the complexity of developing enterprise-level applications. This framework is also called the “framework of frameworks” as spring provides support to various other important frameworks like JSF, Hibernate, Structs, EJB, etc.
  • There are around 20 modules which are generalized into the following types:
    Core Container

    核心容器
    Data Access/Integration
    数据访问/集成
    Web
    Web
    AOP (Aspect Oriented Programming)
    AOP(面向切面编程)
    Instrumentation
    仪器化
    Messaging
    消息传递
    Test
    测试
    Spring handles all the infrastructure-related aspects which lets the programmer to focus mostly on application development.
    Spring处理所有与基础设施相关的方面,这让程序员可以主要专注于应用程序开发。

775. What are the features of Spring Boot?

Spring Boot有哪些特性?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79e8 | 官方: 否 | 付费: 否

答案:

  • Spring Boot CLI – This allows you to Groovy / Maven for writing Spring boot application and avoids boilerplate code.
  • Starter Dependency – With the help of this feature, Spring Boot aggregates common dependencies together and eventually improves productivity and reduces the burden on
  • Spring Initializer – This is a web application that helps a developer in creating an internal project structure. The developer does not have to manually set up the structure of the project while making use of this feature.
  • Auto-Configuration – This helps in loading the default configurations according to the project you are working on. In this way, unnecessary WAR files can be avoided.
  • Spring Actuator – Spring boot uses actuator to provide “Management EndPoints” which helps the developer in going through the Application Internals, Metrics etc.
  • Logging and Security – This ensures that all the applications made using Spring Boot are properly secured without any hassle.

776. Differentiate between Spring and Spring Boot.

区分Spring和Spring Boot。
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79eb | 官方: 否 | 付费: 否

答案:

  • The Spring Framework provides multiple features like dependency injection, data binding, aspect-oriented programming (AOP), data access, and many more that help easier development of web applications whereas Spring Boot helps in easier usage of the Spring Framework by simplifying or managing various loosely coupled blocks of Spring which are tedious and have a potential of becoming messy.
  • Spring boot simplifies commonly used spring dependencies and runs applications straight from a command line. It also doesn’t require an application container and it helps in monitoring several components and configures them externally.

777. Explain the advantages of using Spring Boot for application development.

解释使用Spring Boot进行应用程序开发的优点。
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79ee | 官方: 否 | 付费: 否

答案:

  • Spring Boot helps to create stand-alone applications which can be started using java.jar (Doesn’t require configuring WAR files).
  • Spring Boot also offers pinpointed ‘started’ POMs to Maven configuration.
  • Has provision to embed Undertow, Tomcat, Jetty, or other web servers directly.
  • Auto-Configuration: Provides a way to automatically configure an application based on the dependencies present on the classpath.
  • Spring Boot was developed with the intention of lessening the lines of code.
  • It offers production-ready support like monitoring and apps developed using spring boot are easier to launch.

778. What do you understand by the term ‘Spring Boot’?

你如何理解“Spring Boot”这个术语?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79f1 | 官方: 否 | 付费: 否

答案:

Spring Boot is an open-source, java-based framework that provides support for Rapid Application Development and gives a platform for developing stand-alone and production-ready spring applications with a need for very few configurations.

Spring Boot是一个基于Java的开源框架,它为快速应用程序开发提供支持,并为开发独立且生产就绪的Spring应用程序提供一个平台,且只需很少的配置。

779. What does @SpringBootApplication annotation do internally?

@SpringBootApplication注解在内部做了什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79f4 | 官方: 否 | 付费: 否

答案:

As per the Spring Boot documentation, the @SpringBootApplication annotation is one point replacement for using @Configuration, @EnableAutoConfiguration and @ComponentScan annotations alongside their default attributes.

根据Spring Boot文档,@SpringBootApplication注解是使用@Configuration、@EnableAutoConfiguration和@ComponentScan注解及其默认属性的一站式替代方案。

This enables the developer to use a single annotation instead of using multiple annotations thus lessening the lines of code. However, Spring provides loosely coupled features which is why we can use these annotations as per our project needs.

这使得开发者可以使用单个注解而不是多个注解,从而减少了代码行数。然而,Spring提供了松耦合的特性,这就是为什么我们可以根据项目需求使用这些注解的原因。

780. What are the uses of @RequestMapping and @RestController annotations in Spring Boot?

在Spring Boot中,@RequestMapping和@RestController注解的用途是什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79f7 | 官方: 否 | 付费: 否

答案:

  • @RequestMapping:
    This provides the routing information and informs Spring that any HTTP request matching the URL must be mapped to the respective method.

    这提供了路由信息,并告知Spring任何匹配该URL的HTTP请求都必须映射到相应的方法。
    org.springframework.web.bind.annotation.RequestMapping has to be imported to use this annotation. - @RestController:
    必须导入org.springframework.web.bind.annotation.RequestMapping才能使用此注解。- @RestController:
    This is applied to a class to mark it as a request handler thereby creating RESTful web services using Spring MVC. This annotation adds the @ResponseBody and @Controller annotation to the class.
    这应用于类以将其标记为请求处理器,从而使用Spring MVC创建RESTful Web服务。此注解将@ResponseBody和@Controller注解添加到该类中。

org.springframework.web.bind.annotation.RestController has to be imported to use this annotation.

必须导入org.springframework.web.bind.annotation.RestController才能使用此注解。

Check out more Interview Questions on Spring Boot here .

在此处查看更多Spring Boot面试问题。

781. Can the default web server in the Spring Boot application be disabled?

是否可以禁用Spring Boot应用程序中的默认Web服务器?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc79fb | 官方: 否 | 付费: 否

答案:

Yes! application.properties is used to configure the web application type, by mentioning spring.main.web-application-type=none .

是的!通过提及spring.main.web-application-type=none,使用application.properties来配置Web应用程序类型。

782. How to disable specific auto-configuration class?

如何禁用特定的自动配置类?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a05 | 官方: 否 | 付费: 否

答案:

  • You can use the exclude attribute of @EnableAutoConfiguration for this purpose as shown below:

@EnableAutoConfiguration(exclude = {InterviewBitAutoConfiguration.class})

@EnableAutoConfiguration(exclude = {InterviewBitAutoConfiguration.class})
If the class is not specified on the classpath, we can specify the fully qualified name as the value for the excludeName .
如果类未在类路径中指定,我们可以将完全限定的类名指定为excludeName的值。

//By using "excludeName"

// 通过使用“excludeName”
@EnableAutoConfiguration(excludeName={Foo.class})
@EnableAutoConfiguration(excludeName={Foo.class})
  • You can add into the application.properties and multiple classes can be added by keeping it comma-separated.

783. Can you tell how to exclude any package without using the basePackages filter?

你能告诉我如何在不使用basePackages过滤器的情况下排除任何包吗?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a08 | 官方: 否 | 付费: 否

答案:

We can use the exclude attribute while using the annotation @SpringBootApplication as follows:

我们可以在使用@SpringBootApplication注解时使用exclude属性,如下所示:

@SpringBootApplication(exclude= {Student.class})

@SpringBootApplication(exclude= {Student.class})
public class InterviewBitAppConfiguration {}
public class InterviewBitAppConfiguration {}

784. Can we change the default port of the embedded Tomcat server in Spring boot?

我们能在Spring Boot中更改嵌入式Tomcat服务器的默认端口吗?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a0b | 官方: 否 | 付费: 否

答案:

  • Yes, we can change it by using the application properties file by adding a property of server.port and assigning it to any port you wish to.
  • For example, if you want the port to be 8081, then you have to mention server.port=8081. Once the port number is mentioned, the application properties file will be automatically loaded by Spring Boot and the specified configurations will be applied to the application.

785. What are the possible sources of external configuration?

外部配置的可能来源有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a0e | 官方: 否 | 付费: 否

答案:

  • Spring Boot allows the developers to run the same application in different environments by making use of its feature of external configuration. This uses environment variables, properties files, command-line arguments, YAML files, and system properties to mention the required configuration properties for its corresponding environments. Following are the sources of external configuration:

Command-line properties – Spring Boot provides support for command-line arguments and converts these arguments to properties and then adds them to the set of environment properties.

命令行属性——Spring Boot支持命令行参数,并将这些参数转换为属性,然后将它们添加到环境属性集合中。
Application Properties – By default, Spring Boot searches for the application properties file or its YAML file in the current directory of the application, classpath root, or config directory to load the properties.
应用程序属性——默认情况下,Spring Boot在应用程序的当前目录、类路径根目录或config目录中搜索application properties文件或其YAML文件来加载属性。

Profile-specific properties – Properties are loaded from the application-{profile}.properties file or its YAML file. This file resides in the same location as that of the non-specific property files and the {profile} placeholder refers to an active profile or an environment.

配置文件特定的属性——属性从application-{profile}.properties文件或其YAML文件中加载。该文件与非特定的属性文件位于相同位置,{profile}占位符指的是活跃的配置文件或环境。

786. What is Spring Boot dependency management system?

什么是Spring Boot依赖管理系统?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a11 | 官方: 否 | 付费: 否

答案:

  • It is basically used to manage dependencies and configuration automatically without the need of specifying the version for any of that dependencies.

787. What are the effects of running Spring Boot Application as “Java Application”?

将Spring Boot应用程序作为“Java应用程序”运行会产生什么影响?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a14 | 官方: 否 | 付费: 否

答案:

  • The application automatically launches the tomcat server as soon as it sees that we are running a web application.

788. What is Spring AOP?

什么是Spring AOP?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5858d557c902bc7a17 | 官方: 否 | 付费: 否

答案:

  • Spring AOP (Aspect Oriented Programming) is similar to OOPs (Object Oriented Programming) as it also provides modularity.
  • In AOP key unit is aspects or concerns which are nothing but stand-alone modules in the application. Some aspects have centralized code but other aspects may be scattered or tangled code like in the case of logging or transactions. These scattered aspects are called cross-cutting concern.A cross-cutting concern such as transaction management, authentication, logging, security etc is a concern that could affect the whole application and should be centralized in one location in code as much as possible for security and modularity purposes.
  • AOP provides platform to dynamically add these cross-cutting concerns before, after or around the actual logic by using simple pluggable configurations.
  • This results in easy maintainenance of code. Concerns can be added or removed simply by modifying configuration files and therefore without the need for recompiling complete sourcecode.
  • There are 2 types of implementing Spring AOP:
    Using XML configuration files

    使用XML配置文件
    Using AspectJ annotation style
    使用AspectJ注解风格

789. What is HibernateTemplate class?

什么是 HibernateTemplate 类?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a1a | 官方: 否 | 付费: 否

答案:

  • Prior to Hibernate 3.0.1, Spring provided 2 classes namely: HibernateDaoSupport to get the Session from Hibernate and HibernateTemplate for Spring transaction management purposes.
  • However, from Hibernate 3.0.1 onwards, by using HibernateTemplate class we can use SessionFactory getCurrentSession() method to get the current session and then use it to get the transaction management benefits.
  • HibernateTemplate has the benefit of exception translation but that can be achieved easily by using @Repository annotation with service classes.

790. What is Hibernate Validator Framework?

什么是 Hibernate Validator 框架?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a1d | 官方: 否 | 付费: 否

答案:

  • Data validation is a crucial part of any application. We can find data validation in:
    UI layer before sending objects to the server

    在将对象发送到服务器之前的 UI 层
    At the server-side before processing it
    在服务器端处理之前
    Before persisting data into the database
    在将数据持久化到数据库之前
  • Validation is a cross-cutting concern/task, so as good practice, we should try to keep it apart from our business logic. JSR303 and JSR349 provide specifications for bean validation by using annotations.
  • This framework provides the reference implementation for JSR303 and JSR349 specifications.

791. What are the two ways of accessing Hibernate by using Spring.

使用 Spring 访问 Hibernate 的两种方式是什么?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a20 | 官方: 否 | 付费: 否

答案:

  • Inversion of Control approach by using Hibernate Template and Callback.
  • Extending HibernateDAOSupport and Applying an AOP Interceptor node.

792. What is Hibernate ORM Framework?

什么是 Hibernate ORM 框架?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a23 | 官方: 否 | 付费: 否

答案:

  • Object-relational mapping (ORM) is the phenomenon of mapping application domain model objects to the relational database tables and vice versa.
  • Hibernate is the most commonly used java based ORM framework.

793. How can you fetch records by Spring JdbcTemplate?

如何通过 Spring JdbcTemplate 获取记录?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a26 | 官方: 否 | 付费: 否

答案:

This can be done by using the query method of JdbcTemplate. There are two interfaces that help to do this: - ResultSetExtractor:

这可以通过使用 JdbcTemplate 的 query 方法来实现。有两个接口有助于实现这一点: - ResultSetExtractor:
It defines only one method extractData that accepts ResultSet instance as a parameter and returns the list. Syntax:
它只定义一个方法 extractData,该方法接受 ResultSet 实例作为参数并返回列表。语法:

public T extractData(ResultSet rs) throws SQLException,DataAccessException;

public T extractData(ResultSet rs) throws SQLException,DataAccessException;
  • RowMapper:
    This is an enhanced version of ResultSetExtractor that saves a lot of code.

    这是 ResultSetExtractor 的增强版本,节省了大量代码。
    It allows to map a row of the relations with the instance of the user-defined class.
    它允许将关系中的一行映射到用户定义类的实例。
    It iterates the ResultSet internally and adds it into the result collection thereby saving a lot of code to fetch records.
    它在内部迭代 ResultSet 并将其添加到结果集合中,从而节省了大量获取记录的代码。

794. What are some of the classes for Spring JDBC API?

Spring JDBC API 的一些类有哪些?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a29 | 官方: 否 | 付费: 否

答案:

  • Following are the classes
    JdbcTemplate

    JdbcTemplate
    SimpleJdbcTemplate
    SimpleJdbcTemplate
    NamedParameterJdbcTemplate
    NamedParameterJdbcTemplate
    SimpleJdbcInsert
    SimpleJdbcInsert
    SimpleJdbcCall
    SimpleJdbcCall
  • The most commonly used one is JdbcTemplate. This internally uses the JDBC API and has the advantage that we don’t need to create connection, statement, start transaction, commit transaction, and close connection to execute different queries. All these are handled by JdbcTemplate itself. The developer can focus on executing the query directly.

795. What is Spring AOP Proxy pattern?

什么是Spring AOP代理模式?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a2c | 官方: 否 | 付费: 否

答案:

  • A proxy pattern is a well-used design pattern where a proxy is an object that looks like another object but adds special functionality to it behind the scenes.
  • Spring AOP follows proxy-based pattern and this is created by the AOP framework to implement the aspect contracts in runtime.
  • The standard JDK dynamic proxies are default AOP proxies that enables any interface(s) to be proxied. Spring AOP can also use CGLIB proxies that are required to proxy classes, rather than interfaces. In case a business object does not implement an interface, then CGLIB proxies are used by default.

796. What is an advice? Explain its types in spring.

什么是通知?解释Spring中通知的类型。
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a2f | 官方: 否 | 付费: 否

答案:

An advice is the implementation of cross-cutting concerns can be applied to other modules of the spring application. Advices are of mainly 5 types: - Before:

通知是横切关注点的实现,可以应用于Spring应用程序的其他模块。通知主要有5种类型:- Before(前置):
This advice executes before a join point, but it does not have the ability to prevent execution flow from proceeding to the join point (unless it throws an exception). To use this, use @Before annotation. - AfterReturning:
此通知在连接点之前执行,但它没有能力阻止执行流程继续到连接点(除非它抛出异常)。要使用此通知,请使用@Before注解。- AfterReturning(返回后):
This advice is to be executed after a join point completes normally i.e if a method returns without throwing an exception. To use this, use @AfterReturning annotation. - AfterThrowing:
此通知在连接点正常完成(即方法返回且未抛出异常)之后执行。要使用此通知,请使用@AfterReturning注解。- AfterThrowing(抛出异常后):
This advice is to be executed if a method exits by throwing an exception. To use this, use @AfterThrowing annotation. - After:
如果方法因抛出异常而退出,则执行此通知。要使用此通知,请使用@AfterThrowing注解。- After(后置):
This advice is to be executed regardless of the means by which a join point exits (normal return or exception encounter). To use this, use @After annotation. - Around:
无论连接点以何种方式退出(正常返回或遇到异常),此通知都会执行。要使用此通知,请使用@After注解。- Around(环绕):
This is the most powerful advice surrounds a join point such as a method invocation. To use this, use @Around annotation.
这是最强大的通知,它环绕连接点(如方法调用)。要使用此通知,请使用@Around注解。

797. How can you achieve thread-safety in beans?

如何在Bean中实现线程安全?
  • 知识点: 后端 / 编程语言基础 / 行为与软技能 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: behavioral | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a32 | 官方: 否 | 付费: 否

答案:

The thread safety can be achieved by changing the scope of the bean to request, session or prototype but at the cost of performance. This is purely based on the project requirements.

线程安全可以通过将Bean的作用域更改为请求、会话或原型来实现,但代价是性能受影响。这完全取决于项目需求。

798. Is there any need to keepspring-mvc.jar on the classpath or is it already present as part of spring-core?

是否需要在类路径中保留spring-mvc.jar,还是它已经作为spring-core的一部分存在?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a35 | 官方: 否 | 付费: 否

答案:

The spring-mv.jar does not belong to the spring-core. This means that the jar has to be included in the project’s classpath if we have to use the Spring MVC framework in our project. For Java applications, the spring-mvc.jar is placed inside /WEB-INF/lib folder.

spring-mvc.jar不属于spring-core。这意味着如果要在项目中使用Spring MVC框架,必须将该jar包含在项目的类路径中。对于Java应用程序,spring-mvc.jar放置在/WEB-INF/lib文件夹内。

799. What are Spring Interceptors?

什么是Spring拦截器?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a38 | 官方: 否 | 付费: 否

答案:

Spring Interceptors are used to pre-handle and post-handle the web requests in Spring MVC which are handled by Spring Controllers. This can be achieved by the HandlerInterceptor interface. These handlers are used for manipulating the model attributes that are passed to the controllers or the views. The Spring handler interceptor can be registered for specific URL mappings so that it can intercept only those requests. The custom handler interceptor must implement the HandlerInterceptor interface that has 3 callback methods that can be implemented: - preHandle()

Spring拦截器用于在Spring MVC中预处理和后处理由Spring控制器处理的Web请求。这可以通过HandlerInterceptor接口实现。这些处理器用于操作传递给控制器或视图的模型属性。Spring处理器拦截器可以注册到特定的URL映射,以便只拦截那些请求。自定义处理器拦截器必须实现HandlerInterceptor接口,该接口有3个可实现的回调方法:- preHandle()
  • postHandle()
  • afterCompletion()
    The only problem with this interface is that all the methods of this interface need to be implemented irrespective of its requirements. This can be avoided if our handler class extends the HandlerInterceptorAdapter class that internally implements the HandlerInterceptor interface and provides default blank implementations.

    这个接口唯一的问题是,无论需求如何,都必须实现该接口的所有方法。如果我们的处理类继承HandlerInterceptorAdapter类,可以避免这种情况,该类内部实现了HandlerInterceptor接口并提供默认的空白实现。

800. Why do we need BindingResults?

为什么我们需要BindingResults?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a3b | 官方: 否 | 付费: 否

答案:

BindingResults is an important Spring interface that is within the org.Springframework.validation package. This interface has a very simple and easy process of invocation and plays a vital role in detecting errors in the submitted forms. However, care has to be taken by the developer to use the BindingResult parameter just after the object that needs validation. For example:

BindingResults是一个重要的Spring接口,位于org.Springframework.validation包中。该接口具有非常简单易用的调用过程,在检测提交表单中的错误方面起着关键作用。然而,开发者必须注意,BindingResult参数必须紧跟在需要验证的对象之后使用。例如:

@PostMapping("/interviewbit")

@PostMapping("/interviewbit")
public String registerCourse(@Valid RegisterUser registerUser,
public String registerCourse(@Valid RegisterUser registerUser,
BindingResult bindingResult, Model model) {
BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
if (bindingResult.hasErrors()) {
return "home";
return “home”;
}
model.addAttribute("message", "Valid inputs");
model.addAttribute(“message”, “Valid inputs”);
return "home";
return “home”;
}
The Spring will understand to find the corresponding validators by checking the @Valid annotation on the parameter.
Spring会通过检查参数上的@Valid注解来理解如何找到相应的验证器。

801. Where does the access to the model from the view come from?

视图对模型的访问从何而来?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a3e | 官方: 否 | 付费: 否

答案:

The view requires access to the model to render the output as the model contains the required data meant for rendering. The model is associated with the controller that processes the client requests and finally encapsulates the response into the Model object.

视图需要访问模型来渲染输出,因为模型包含用于渲染所需的数据。模型与处理客户端请求的控制器相关联,并最终将响应封装到Model对象中。

802. How does the Spring MVC flow look like? In other words, How does a DispatcherServlet know what Controller needs to be called when there is an incoming request to the Spring MVC?

Spring MVC的流程是什么样的?换句话说,当有请求进入Spring MVC时,DispatcherServlet如何知道需要调用哪个控制器?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a41 | 官方: 否 | 付费: 否

答案:

A Dispatcher Servlet knows which controller to call by means of handler mappings. These mappings have the mapping between the controller and the requests. BeanNameUrlHandlerMapping and SimpleUrlHandlerMapping are the two most commonly used handler mappings. - BeanNameUrlHandlerMapping: When the URL request matches the bean name, the class corresponding to the bean definition is the actual controller that is responsible for processing the request.

Dispatcher Servlet通过处理器映射(handler mappings)知道该调用哪个控制器。这些映射定义了控制器与请求之间的对应关系。BeanNameUrlHandlerMapping和SimpleUrlHandlerMapping是两种最常用的处理器映射。- BeanNameUrlHandlerMapping: 当URL请求与bean名称匹配时,bean定义对应的类就是负责处理该请求的实际控制器。
  • SimpleUrlHandlerMapping: Here, the mapping is very explicit. The number of URLs can be specified here and each URL is associated explicitly with a controller.
    If the Spring MVC is configured using annotations, then @RequestMapping annotations are used for this purpose. The @RequestMapping annotation is configured by making use of the URI path, HTTP methods, query parameters, and the HTTP Headers.

    如果Spring MVC使用注解进行配置,那么@RequestMappping注解就用于此目的。@RequestMapping注解通过使用URI路径、HTTP方法、查询参数和HTTP头来配置。

803. How is the root application context in Spring MVC loaded?

Spring MVC中的根应用上下文是如何加载的?
  • 知识点: 后端 / 编程语言基础 (主题: spring, java, backend;标签: interviewbit, spring, topic-specific, java, backend)
  • 类型: technical | 难度: medium | 子类型: concept
  • 分类: fullstack
  • id: 69b37c5958d557c902bc7a44 | 官方: 否 | 付费: 否

答案:

The root application context is loaded using the ContextLoaderListener that belongs to the entire application. Spring MVC allows instantiating multiple DispatcherServlet and each of them have multiple contexts specific to them. They can have the same root context too.

根应用上下文通过属于整个应用程序的ContextLoaderListener进行加载。Spring MVC允许实例化多个DispatcherServlet,每个DispatcherServlet都有各自特定的多个上下文。它们也可以共享同一个根上下文。
0

评论

博主关闭了当前页面的评论
EN