\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{woshiamiaojiang} \pdfinfo{ /Title (rakuten-interview-questions.pdf) /Creator (Cheatography) /Author (woshiamiaojiang) /Subject (Rakuten Interview Questions Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Rakuten Interview Questions Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{woshiamiaojiang} via \textcolor{DarkBackground}{\uline{cheatography.com/193748/cs/40392/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}woshiamiaojiang \\ \uline{cheatography.com/woshiamiaojiang} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 22nd September, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{code review consideration}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Code style \newline % Row Count 1 (+ 1) Tests \newline % Row Count 2 (+ 1) Documentation \newline % Row Count 3 (+ 1) iplementation Semantics \newline % Row Count 4 (+ 1) API Semantics \newline % Row Count 5 (+ 1) Functionality and Requirements: \newline % Row Count 6 (+ 1) Code Clarity and Readability: \newline % Row Count 7 (+ 1) Code Style and Formatting: \newline % Row Count 8 (+ 1) Error Handling: \newline % Row Count 9 (+ 1) Testing and Test Coverage: \newline % Row Count 10 (+ 1) Performance and Scalability \newline % Row Count 11 (+ 1) Security \newline % Row Count 12 (+ 1) Concurrency and Thread Safety \newline % Row Count 13 (+ 1) Documentation \newline % Row Count 14 (+ 1) Logging and Debugging \newline % Row Count 15 (+ 1) easy to Maintainability and Extensibility \newline % Row Count 16 (+ 1) Code Comments% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{pro and con of microservices vs monolithic}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Microservices Architecture: \newline % Row Count 1 (+ 1) Scalability \newline % Row Count 2 (+ 1) Flexibility \newline % Row Count 3 (+ 1) Modularity \newline % Row Count 4 (+ 1) Rapid Development: \newline % Row Count 5 (+ 1) Fault Isolate \newline % Row Count 6 (+ 1) Continuous Delivery: \newline % Row Count 7 (+ 1) Monolithic Architecture: \newline % Row Count 8 (+ 1) not complexity \newline % Row Count 9 (+ 1) Performance \newline % Row Count 10 (+ 1) Easier Debugging \newline % Row Count 11 (+ 1) Development Speed% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{microservice architecture system design}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Decomposition of Services: \newline % Row Count 1 (+ 1) Service Boundaries: \newline % Row Count 2 (+ 1) API Design: \newline % Row Count 3 (+ 1) Data Management: \newline % Row Count 4 (+ 1) 服务配置中心 \newline % Row Count 5 (+ 1) 服务发现 \newline % Row Count 6 (+ 1) 服务负载均衡 \newline % Row Count 7 (+ 1) 容错机制 Fault Tolerance and Resilience: \newline % Row Count 8 (+ 1) timeout, circuit breaker, downgrade, rate limit, retry \newline % Row Count 10 (+ 2) 日志与监控,告警 skywalking / Prometheus \& Grafana Application performance monitor tool for distributed systems \newline % Row Count 13 (+ 3) 数据一致性问题 \newline % Row Count 14 (+ 1) Logging and Monitoring: \newline % Row Count 15 (+ 1) Security: \newline % Row Count 16 (+ 1) Deployment and Orchestration: \newline % Row Count 17 (+ 1) Continuous Integration and Deployment (CI/CD):% Row Count 18 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Linux中 JVM常用命令}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{top \newline % Row Count 1 (+ 1) top -Hp PID \seqsplit{查看占用CPU最高的进程的线程情况} \newline % Row Count 3 (+ 2) \seqsplit{确定线程后,计算线程ID对应的十六进制值:} printf "\%x\textbackslash{}n" \textless{}java\_thread\_id\textgreater{} \newline % Row Count 5 (+ 2) \seqsplit{将该线程堆栈内容输出:} jstack \textless{}java\_pid\textgreater{} | grep \textless{}线程id十六进制值\textgreater{} -A 30 【-A \seqsplit{30表示向下打印30行】} \newline % Row Count 8 (+ 3) \seqsplit{ps:ps命令用于列出当前运行的进程。} \newline % Row Count 9 (+ 1) ps aux | grep java \newline % Row Count 10 (+ 1) \seqsplit{jps:它通常用于查找正在运行的Java进程。} \newline % Row Count 12 (+ 2) \seqsplit{jstack:jstack命令用于生成Java线程转储,以便分析Java应用程序中的线程状态和堆栈信息。你需要提供Java进程的PID。} \newline % Row Count 16 (+ 4) jstack \textless{}PID\textgreater{} \newline % Row Count 17 (+ 1) \seqsplit{jmap:jmap命令用于生成Java进程的内存映像。它可以用于查看堆内存使用情况和分析内存泄漏。} \newline % Row Count 20 (+ 3) jmap -heap \textless{}PID\textgreater{} \newline % Row Count 21 (+ 1) \seqsplit{jstat:jstat命令用于监视Java应用程序的性能统计信息,如垃圾回收统计和类加载统计。} \newline % Row Count 24 (+ 3) jstat -gc \textless{}PID\textgreater{} \newline % Row Count 25 (+ 1) \seqsplit{jcmd:jcmd命令提供了对Java进程的广泛管理和诊断功能。你可以使用它来执行各种操作,如线程转储、堆转储、性能监视等。} \newline % Row Count 29 (+ 4) jcmd \textless{}PID\textgreater{} \textless{}命令\textgreater{} \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Linux中 JVM常用命令 (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{jconsole:jconsole是Java自带的可视化监控工具,用于监视和管理Java应用程序的性能和资源使用情况。}% Row Count 3 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{API to handle large amount of traffic}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{rate limit in the api gateway \newline % Row Count 1 (+ 1) pagnation \newline % Row Count 2 (+ 1) cache \newline % Row Count 3 (+ 1) load test jemeter \newline % Row Count 4 (+ 1) Scalable Architecture: \newline % Row Count 5 (+ 1) Use Efficient Protocols: \newline % Row Count 6 (+ 1) Caching: \newline % Row Count 7 (+ 1) Throttling and Rate Limiting: \newline % Row Count 8 (+ 1) Asynchronous Processing: \newline % Row Count 9 (+ 1) Content Delivery Networks (CDNs): \newline % Row Count 10 (+ 1) Authentication and Authorization: \newline % Row Count 11 (+ 1) Monitoring and Analytics: \newline % Row Count 12 (+ 1) Error Handling and Status Codes: \newline % Row Count 13 (+ 1) Pagination and Filtering: \newline % Row Count 14 (+ 1) API Versioning: \newline % Row Count 15 (+ 1) Security: \newline % Row Count 16 (+ 1) Protect against common security threats, such as SQL injection, Cross-Site Scripting (XSS), and Cross-Site Request Forgery (CSRF). \newline % Row Count 19 (+ 3) Employ security headers and encryption (e.g., TLS/SSL) for data protection. \newline % Row Count 21 (+ 2) Documentation and Developer Support: \newline % Row Count 22 (+ 1) Testing and Load Testing: \newline % Row Count 23 (+ 1) Failover and Redundancy: \newline % Row Count 24 (+ 1) Rate Monitoring and Billing: \newline % Row Count 25 (+ 1) Feedback and Improvement:% Row Count 26 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{difference between Rest and GraphQL API}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/woshiamiaojiang_1695304740_Snipaste_2023-09-21_21-58-05.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{API}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{when you build your api , What technology and what kind of protocol do you use? \newline % Row Count 2 (+ 2) Programming Languages \newline % Row Count 3 (+ 1) Web Frameworks \newline % Row Count 4 (+ 1) Data Storage \newline % Row Count 5 (+ 1) Protocol: \newline % Row Count 6 (+ 1) HTTP/HTTPS \newline % Row Count 7 (+ 1) WebSocket \newline % Row Count 8 (+ 1) GraphQL \newline % Row Count 9 (+ 1) gRPC \newline % Row Count 10 (+ 1) Authentication and Authorization: APIs often require authentication and authorization mechanisms to secure access to data. Common methods include API keys, OAuth 2.0, JWT (JSON Web Tokens), and OAuth 2.0. \newline % Row Count 15 (+ 5) Documentation \newline % Row Count 16 (+ 1) Testing \newline % Row Count 17 (+ 1) Versioning \newline % Row Count 18 (+ 1) Rate Limiting and Throttling \newline % Row Count 19 (+ 1) Monitoring and Logging \newline % Row Count 20 (+ 1) Security \newline % Row Count 21 (+ 1) Load Balancing% Row Count 22 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{high traffic API checklist}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{1. Performance Testing \newline % Row Count 1 (+ 1) 2. Security Testing \newline % Row Count 2 (+ 1) 3. Error Handling \newline % Row Count 3 (+ 1) 4. Rate Limiting \newline % Row Count 4 (+ 1) 5. Caching \newline % Row Count 5 (+ 1) 6. Logging and Monitoring \newline % Row Count 6 (+ 1) 7. Documentation \newline % Row Count 7 (+ 1) 8. Versioning \newline % Row Count 8 (+ 1) 9. Backup and Recovery \newline % Row Count 9 (+ 1) 10. Deployment Strategy \newline % Row Count 10 (+ 1) 11. Rollback Strategy \newline % Row Count 11 (+ 1) 12. API Throttling% Row Count 12 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{why hashmap expand at the threadhold of 0.75?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Minimizing Collisions: A lower load factor would lead to fewer collisions because it would create more buckets (and therefore a smaller number of entries in each bucket). However, if the load factor is set too low, the HashMap would require frequent resizing, which is an expensive operation. \newline % Row Count 6 (+ 6) Avoiding Frequent Resizing: Resizing a HashMap involves creating a new, larger array and copying all the existing elements into the new array. This is a computationally expensive operation and can lead to performance degradation if it occurs frequently. A load factor of 0.75 strikes a balance between reducing collisions and minimizing the number of resizes. \newline % Row Count 14 (+ 8) Memory Efficiency: While a lower load factor would reduce collisions, it would also increase memory usage because it would require more buckets. A higher load factor would reduce memory usage but increase the likelihood of collisions. A load factor of 0.75 aims to strike a balance between these considerations, providing a reasonable compromise between memory efficiency and performance. \newline % Row Count 22 (+ 8) Average-Case Performance: A load factor of 0.75 is chosen to ensure that, on average, buckets remain reasonably small, keeping the lookup, insertion, and removal operations close to constant time (O(1)) in typical scenarios. It provides good performance for a wide range of use cases.% Row Count 28 (+ 6) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{hashmap thread safe}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{在 jdk1.7 \seqsplit{中,头插法,在多线程环境下,扩容时会造成环形链或数据丢失。} \newline % Row Count 2 (+ 2) 在 jdk1.8 \seqsplit{中,尾插法,在多线程环境下,会发生数据覆盖的情况。} \newline % Row Count 4 (+ 2) If you need high concurrency and performance, consider using ConcurrentHashMap. \newline % Row Count 6 (+ 2) If you have an existing HashMap and want to make it thread-safe with minimal changes, you can wrap it using \seqsplit{Collections.synchronizedMap().} \newline % Row Count 9 (+ 3) If you require a legacy thread-safe solution, Hashtable is an option.% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{byte type and what byte type in Java}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Size: A byte is 8 bits, which means it can represent 2\textasciicircum{}8 (256) distinct values. In the case of signed integers, the range is typically from -128 to 127. \newline % Row Count 4 (+ 4) Signed: In Java, byte is a signed data type \newline % Row Count 5 (+ 1) Default Value: The default value of a byte variable is 0. \newline % Row Count 7 (+ 2) byte myByte = 42; // Assigning a positive value% Row Count 8 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{tuning weblogic or something about tomcat}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{configJVM \newline % Row Count 1 (+ 1) configThread Pool \newline % Row Count 2 (+ 1) using NIO \newline % Row Count 3 (+ 1) config Connection Pools \newline % Row Count 4 (+ 1) CDN or Nginx offload static content% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{SpringBoot authrization}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{@SpringBootApplication \newline public class SpringBootApiExample \{ \newline \newline public static void main(String{[}{]} args) \{ \newline \seqsplit{SpringApplication.run(SpringBootApiExample.class}, args); \newline \} \newline \newline // DTO (Data Transfer Object) class for request body validation \newline @Validated \newline static class RequestData \{ \newline @NotBlank(message = "Message cannot be blank") \newline private String message; \newline \newline public String getMessage() \{ \newline return message; \newline \} \newline \newline public void setMessage(String message) \{ \newline this.message = message; \newline \} \newline \} \newline \newline // Custom exception handler for 400 Bad Request and 500 Internal Server Error \newline @RestControllerAdvice \newline static class CustomExceptionHandler \{ \newline \seqsplit{@ExceptionHandler(MethodArgumentNotValidException}.class) \newline ResponseEntity\textless{}String\textgreater{} \seqsplit{handleValidationException(MethodArgumentNotValidException} ex) \{ \newline String errorMessage = \seqsplit{ex.getBindingResult().getFieldError().getDefaultMessage();} \newline return \seqsplit{ResponseEntity.status(HttpStatus.BAD\_REQUEST).body(errorMessage);} \newline \} \newline \newline \seqsplit{@ExceptionHandler(Exception}.class) \newline ResponseEntity\textless{}String\textgreater{} \seqsplit{handleInternalServerError(Exception} ex) \{ \newline return \seqsplit{ResponseEntity.status(HttpStatus.INTERNAL\_SERVER\_ERROR).body("Internal} Server Error"); \newline \} \newline \} \newline \newline // POST endpoint with request body validation and authorization check \newline \seqsplit{@PostMapping("/api/post")} \newline @Secured("ROLE\_USER") \newline ResponseEntity\textless{}String\textgreater{} postEndpoint( \newline @Valid @RequestBody RequestData requestData, \newline @AuthenticationPrincipal User authenticatedUser \newline ) \{ \newline // You can access the authenticated user's information if needed \newline String username = \seqsplit{authenticatedUser.getUsername();} \newline \newline // Process the request data (e.g., save it to a database) \newline String message = \seqsplit{requestData.getMessage();} \newline return \seqsplit{ResponseEntity.ok("Received} POST request with message: " + message); \newline \} \newline \newline // GET endpoint with authorization check \newline @GetMapping("/api/get") \newline @Secured("ROLE\_ADMIN") \newline ResponseEntity\textless{}String\textgreater{} getEndpoint() \{ \newline // Process the GET request \newline return \seqsplit{ResponseEntity.ok("Received} GET request"); \newline \} \newline \}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{DB system}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{what database system: \newline % Row Count 1 (+ 1) ralational : mysql , postgre, oracle \newline % Row Count 2 (+ 1) nosql \newline % Row Count 3 (+ 1) 列式column-based \seqsplit{:HBase、Cassandra、ClickHouse} \newline % Row Count 5 (+ 2) \seqsplit{键值:Redis、Memcached} \newline % Row Count 6 (+ 1) 文档 doc:MongoDB \newline % Row Count 7 (+ 1) 时序time-series :InfluxDB、Prometheus \newline % Row Count 8 (+ 1) 搜索:Elasticsearch \newline % Row Count 9 (+ 1) graph : neo4j% Row Count 10 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{multithreading environment}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Concurrency: progress on multiple tasks at the same time. \newline % Row Count 2 (+ 2) Parallelism: Parallelism is a specific form of concurrency。 where multiple threads or processes execute tasks simultaneously on multiple CPU cores or processors. \newline % Row Count 6 (+ 4) Thread Safety: multiple threads access shared data simultaneously. \newline % Row Count 8 (+ 2) Race Conditions \newline % Row Count 9 (+ 1) Deadlocks \newline % Row Count 10 (+ 1) Thread Communication: wait/notify (in Java)% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{alert on production on errors}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{tell your team you are dealing with it \newline % Row Count 1 (+ 1) Gather Info \newline % Row Count 2 (+ 1) Assess the severity of the error. \newline % Row Count 3 (+ 1) identify the specific component or service that is causing the error. \newline % Row Count 5 (+ 2) Rollback (if applicable) \newline % Row Count 6 (+ 1) Prioritize the alert based on its impact and urgency \newline % Row Count 8 (+ 2) Notify relevant memebers \newline % Row Count 9 (+ 1) Incident Response Plan \newline % Row Count 10 (+ 1) Root Cause Analysis \newline % Row Count 11 (+ 1) Temporary Fixes \newline % Row Count 12 (+ 1) Testing and Deploy the Fix \newline % Row Count 13 (+ 1) Monitor \newline % Row Count 14 (+ 1) Post-Incident Review \newline % Row Count 15 (+ 1) Documentation and Knowledge Sharing% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{java 1.7 and 1.8?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Lambda Expressions (Java 1.8): \newline % Row Count 1 (+ 1) Functional Interfaces (Java 1.8): \newline % Row Count 2 (+ 1) Stream API (Java 1.8): \newline % Row Count 3 (+ 1) Default Methods (Java 1.8): \newline % Row Count 4 (+ 1) Default methods allow interfaces to provide method implementations. \newline % Row Count 6 (+ 2) Method References (Java 1.8): \newline % Row Count 7 (+ 1) New Date and Time API (Java 1.8): \newline % Row Count 8 (+ 1) PermGen Removal (Java 1.8):introduced the Metaspace memory area. \newline % Row Count 10 (+ 2) Garbage-First (G1) collector as the default collector% Row Count 12 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{how to keep track of performance metrics}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Select Monitoring Tools:Prometheus, Grafana \newline % Row Count 1 (+ 1) Instrument Your Code: \newline % Row Count 2 (+ 1) Set Up Alerts: \newline % Row Count 3 (+ 1) Monitor System Resources: CPU usage, memory usage, disk I/O, and network traffic. \newline % Row Count 5 (+ 2) Application-Level Metrics: Collect application-specific metrics related to your business logic and functionality. \newline % Row Count 8 (+ 3) Custom Metrics: \newline % Row Count 9 (+ 1) Logging and Tracing: \newline % Row Count 10 (+ 1) Dashboards: \newline % Row Count 11 (+ 1) Data Retention Policy: \newline % Row Count 12 (+ 1) Regularly Review and Analyze Metrics: \newline % Row Count 13 (+ 1) Scaling Events: \newline % Row Count 14 (+ 1) Load Testing: \newline % Row Count 15 (+ 1) Documentation: \newline % Row Count 16 (+ 1) Continuous Improvement: \newline % Row Count 17 (+ 1) Security Monitoring: \newline % Row Count 18 (+ 1) Compliance Monitoring:% Row Count 19 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{a database design perspective}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{constructed type, sime-constructed, non-constructed \newline % Row Count 2 (+ 2) db choose \newline % Row Count 3 (+ 1) assuption of total data size \newline % Row Count 4 (+ 1) write qps and read qps \newline % Row Count 5 (+ 1) 1. Data Modeling: \newline % Row Count 6 (+ 1) 2. Indexing: \newline % Row Count 7 (+ 1) 3. Query Optimization: \newline % Row Count 8 (+ 1) 4. Partitioning and Sharding: \newline % Row Count 9 (+ 1) 5. Caching: \newline % Row Count 10 (+ 1) 6. Connection Pooling: \newline % Row Count 11 (+ 1) 7. Data Compression and Archiving: \newline % Row Count 12 (+ 1) 8. Backup and Recovery: \newline % Row Count 13 (+ 1) 9. Monitoring and Tuning: \newline % Row Count 14 (+ 1) 10. Hardware Considerations: \newline % Row Count 15 (+ 1) 11. Security: \newline % Row Count 16 (+ 1) 12. Scalability:% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{asyncrhonous processing}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{用户行为采样,前端把数据放进消息中间件中就返回。然后线程池} \seqsplit{每10S取一批处理做数据清洗,batch放进clickhouse中。} \newline % Row Count 4 (+ 4) \seqsplit{批量下单,多个任务completableFuture同时下单,全部完成后,统计成功与失败个数。} \newline % Row Count 7 (+ 3) \seqsplit{定时任务,统计数据,CountDownLatch,单个线程等待其他线程池完成后作汇总任务。} \newline % Row Count 10 (+ 3) \seqsplit{线程池的任务都是异步的。}% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{microservice arthitecture}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{1. Service Independence \newline % Row Count 1 (+ 1) 2. Single Responsibility \newline % Row Count 2 (+ 1) 3. Decentralization \newline % Row Count 3 (+ 1) 4. API-Based Communication \newline % Row Count 4 (+ 1) 5. Polyglot Persistence \newline % Row Count 5 (+ 1) 6. Independent Data Management \newline % Row Count 6 (+ 1) 7. Resilience \newline % Row Count 7 (+ 1) 8. Scalability \newline % Row Count 8 (+ 1) 9. Continuous Deployment \newline % Row Count 9 (+ 1) 10. Monitoring and Observability \newline % Row Count 10 (+ 1) 11. Docker and Containerization \newline % Row Count 11 (+ 1) 12. Orchestration and Service Discovery \newline % Row Count 12 (+ 1) 13. Event-Driven Architectures \newline % Row Count 13 (+ 1) 14. Incremental Development \newline % Row Count 14 (+ 1) 15. Domain-Driven Design (DDD) \newline % Row Count 15 (+ 1) 16. Security% Row Count 16 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{hashmap Treeify and untreeify 时机}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Treeify (treeifyBin() method): \newline % Row Count 1 (+ 1) Balancing Act: The threshold of 8 is chosen to strike a balance between performance and memory usage. It's an empirical value that, based on extensive testing and analysis, provides a good trade-off for most use cases. When the number of entries in a bucket exceeds 8, the linked list is treeified to improve lookup performance. When the number falls below 6, the tree structure is untreeified to save memory and improve iteration performance.% Row Count 10 (+ 9) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{testing performance test and api test}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{performance testing include: \newline % Row Count 1 (+ 1) Load Testin \newline % Row Count 2 (+ 1) Stress Testing \newline % Row Count 3 (+ 1) Scalability Testing \newline % Row Count 4 (+ 1) Volume Testing \newline % Row Count 5 (+ 1) Endurance Testing \newline % Row Count 6 (+ 1) Spike Testing \newline % Row Count 7 (+ 1) API Testing: \newline % Row Count 8 (+ 1) Functional Testing \newline % Row Count 9 (+ 1) Integration Testing \newline % Row Count 10 (+ 1) Security Testing \newline % Row Count 11 (+ 1) Performance Testing \newline % Row Count 12 (+ 1) Load Testing \newline % Row Count 13 (+ 1) Mocking% Row Count 14 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{kafka rabbit}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/woshiamiaojiang_1695310650_Snipaste_2023-09-21_23-36-12.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{What is the ideal backend architecture design}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{API网关 做限流 \newline % Row Count 1 (+ 1) \seqsplit{微服务,服务拆分,无状态,自动扩缩容} \newline % Row Count 3 (+ 2) NGINX 负载均衡 \newline % Row Count 4 (+ 1) ELK 日志查询 \newline % Row Count 5 (+ 1) prometheus \& grafana 监控告警 \newline % Row Count 6 (+ 1) mysql 分库分表 \seqsplit{高性能,一主多从,读写分离。搜索走ES。} \newline % Row Count 8 (+ 2) redis cluster 高可用 缓存 加快响应 \newline % Row Count 9 (+ 1) 异地多活 multi center of services in different cities \newline % Row Count 11 (+ 2) 全链路压测 \newline % Row Count 12 (+ 1) 定期安全检查 \newline % Row Count 13 (+ 1) CI CD 自动化部署 \newline % Row Count 14 (+ 1) perfect documentation of the whole system \newline % Row Count 15 (+ 1) message queue for asynchronous communication \newline % Row Count 16 (+ 1) 数据库数据备份% Row Count 17 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{CI CD}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{jenkins pipeline \newline % Row Count 1 (+ 1) \seqsplit{第1步.开发(IDE)提交代码} push events \seqsplit{到项目仓库服务器(gitlab);} \newline % Row Count 3 (+ 2) \seqsplit{第2步.jenkins开始执行Pipeline代码文件,开始从(gitlab)仓库git} clone代码; \newline % Row Count 5 (+ 2) \seqsplit{第3步.jenkins启动Pipeline里面第一个stage(阶段);} \newline % Row Count 7 (+ 2) \seqsplit{第4步.图里面第一个Stage从仓库检出(Checkout)代码;} \newline % Row Count 9 (+ 2) \seqsplit{第5步.接着进入第二Stage构建(Build)检出的代码;} \newline % Row Count 11 (+ 2) \seqsplit{第6步.然后进入测试(Test)的阶段,执行各种自动化测试验证;} Sonar \newline % Row Count 13 (+ 2) \seqsplit{第7步.然后测试结束,到运维的部署(Deploy)阶段;} \newline % Row Count 15 (+ 2) \seqsplit{第8步.部署结束,输出报告,整个自动化流程工作完成;}% Row Count 17 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{cookie track}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{你登录某个电商网站,电商网站放了tracking} \seqsplit{cookie在你的浏览器中。} \newline % Row Count 2 (+ 2) \seqsplit{然后登陆了其他网站,这个网站和google} \seqsplit{ads合作,把你的cookie给了google},谷歌看到了这个唯一ID,知道了是电商网站放的,给你推送了那个电商网站的广告。% Row Count 7 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{\seqsplit{redis于rabbitmq和kafka优势}}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{\seqsplit{redis作为消息中间件相对于rabbitmq和kafka有什么优势吗?} \newline % Row Count 2 (+ 2) Redis的优势: \newline % Row Count 3 (+ 1) 低延迟 \newline % Row Count 4 (+ 1) 轻量级 \newline % Row Count 5 (+ 1) 多数据类型支持 \newline % Row Count 6 (+ 1) Redis的限制: \newline % Row Count 7 (+ 1) \seqsplit{消息持久性:如果你需要保证消息不会丢失,特别是在高负载或故障情况下,Kafka可能更适合。} \newline % Row Count 10 (+ 3) \seqsplit{扩展性:扩展性有限。Kafka和RabbitMQ在这方面表现更出色,可以轻松处理高吞吐量的数据流。} \newline % Row Count 13 (+ 3) \seqsplit{消息顺序性:Redis的发布/订阅模型不保证消息的顺序性} \newline % Row Count 15 (+ 2) \seqsplit{消息保持时间:Redis的消息通常是短暂的}% Row Count 17 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{how java's hash map internally work?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Hashing: \newline % Row Count 1 (+ 1) hashCode() \newline % Row Count 2 (+ 1) first 16 and last 16 do exclusive or \% array.length() \newline % Row Count 4 (+ 2) the key-value pair is placed in that bucket. \newline % Row Count 5 (+ 1) no other key-value pair with the same hash code in the bucket, the new pair is added directly. \newline % Row Count 7 (+ 2) Retrieving Values: \newline % Row Count 8 (+ 1) Load Factor and Rehashing: \newline % Row Count 9 (+ 1) HashMap has a load factor (typically 0.75) that determines when it should resize the internal array.% Row Count 11 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{How about maintenance and production?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Prometheus + ELK \newline % Row Count 1 (+ 1) Multi-Site High Availability \newline % Row Count 2 (+ 1) update OS patches \newline % Row Count 3 (+ 1) Backups and Disaster Recovery \newline % Row Count 4 (+ 1) auto-scale \newline % Row Count 5 (+ 1) periodic security audits and vulnerability assessments \newline % Row Count 7 (+ 2) Maintain an incident response plan \newline % Row Count 8 (+ 1) Continuously assess the capacity of your system and anticipate future growth \newline % Row Count 10 (+ 2) Regular testing, including load testing, security testing, and disaster recovery testing \newline % Row Count 12 (+ 2) Keep documentation up to date \newline % Row Count 13 (+ 1) Change Management: \newline % Row Count 14 (+ 1) Maintain SLAs and performance targets for your application or service \newline % Row Count 16 (+ 2) Encourage a culture of continuous improvement within your operations team% Row Count 18 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{memory cache and qps:}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{memory cache and qps: \newline % Row Count 1 (+ 1) single Redis qps benchmark is around 100 thousand. \newline % Row Count 3 (+ 2) Reids Culster can reach around 1 million. \newline % Row Count 4 (+ 1) Cassandra: tens of thousands to hundreds of thousands% Row Count 6 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{figure out JVM memory leak}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{dump easy gc \newline % Row Count 1 (+ 1) \seqsplit{-XX:+HeapDumpOnOutOfMemoryError} \seqsplit{-XX:HeapDumpPath=/path/to/dumpfile} \newline % Row Count 3 (+ 2) Analyze Heap Dumps: \newline % Row Count 4 (+ 1) Once you have a heap dump, you can analyze it using tools like Eclipse Memory Analyzer (MAT) or VisualVM's Heap Dump Analyzer. These tools can help you identify which objects are causing the memory leak.% Row Count 9 (+ 5) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{method of web security}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Input Validation: \newline % Row Count 1 (+ 1) Authentication and Authorization: \newline % Row Count 2 (+ 1) Secure Password + salt \newline % Row Count 3 (+ 1) HTTPS Encryption \newline % Row Count 4 (+ 1) Web Application Firewall (WAF): \newline % Row Count 5 (+ 1) Security Scanning and Testing: \newline % Row Count 6 (+ 1) Penetration Testing \newline % Row Count 7 (+ 1) Rate Limiting: \newline % Row Count 8 (+ 1) Monitor, log, alert \newline % Row Count 9 (+ 1) 1. \seqsplit{身份验证(Authentication):} \newline % Row Count 10 (+ 1) 2. \seqsplit{授权(Authorization):} \newline % Row Count 11 (+ 1) 3. 使用HTTPS: \newline % Row Count 12 (+ 1) 4. \seqsplit{输入验证和数据验证:} \newline % Row Count 13 (+ 1) 5. 防止DDoS攻击: \newline % Row Count 14 (+ 1) 6. 安全标头(Security Headers): \seqsplit{CORS标头、X-Content-Type-Options、X-Frame-Options和Content-Security-Policy} \newline % Row Count 17 (+ 3) Risk control system blacklist \newline % Row Count 18 (+ 1) \seqsplit{重要接口做接口加密:前后端约定加密规则,时间戳+请求参数} 生成 sign% Row Count 20 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{experience about mem cache}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{cache mysql query result \newline % Row Count 1 (+ 1) spring security + cas + redis : user's session \newline % Row Count 2 (+ 1) bitmap 实现 bloomfilter \newline % Row Count 3 (+ 1) bitmap \seqsplit{作为用户签到的统计} \newline % Row Count 4 (+ 1) hyperloglog 统计pv、uv \newline % Row Count 5 (+ 1) zset实现延迟队列 \newline % Row Count 6 (+ 1) distributed lock \newline % Row Count 7 (+ 1) setnx + expire+ \seqsplit{lua脚本把前两个命令封装原子性。问题:单点故障或者分区网络问题,造成锁被他人拿取。无法支持锁的重入,主从模式可能造成锁丢失,锁无法自动续期。} \newline % Row Count 12 (+ 5) \seqsplit{redlock:极端情况下,会造成两个线程同时获得锁。为了避免该种情况发生,要求宕机的redis在超过锁超时时间后再重启。使用锁的时间要小于锁超时时间。} \newline % Row Count 17 (+ 5) \seqsplit{zk:临时顺序节点,每个节点监听前面节点的释放} \newline % Row Count 19 (+ 2) redis rate limit: 三种 \newline % Row Count 20 (+ 1) string, set , expire 实现fixed window counter algorithm \newline % Row Count 22 (+ 2) \seqsplit{zset,value保持唯一,可以用UUID生成,而score可以用timestamp表示,因为score我们可以用来计算当前时间戳之内有多少的请求数量。而zset数据结构也提供了range方法让我们可以很轻易的获取到2个时间戳内有多少请求。} Sliding window log algorithm \newline % Row Count 29 (+ 7) \seqsplit{list的leftPop方法来获取令牌,scheduledJob定时任务rightPush。Token} bucket algorithm \newline % Row Count 31 (+ 2) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{experience about mem cache (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{简单窗口 \newline % Row Count 1 (+ 1) O(1) \newline % Row Count 2 (+ 1) O(1) \newline % Row Count 3 (+ 1) \seqsplit{容易实现,适用于一些简单的流控场景,流量比较均匀,或者允许临界突变} \newline % Row Count 5 (+ 2) 滑动窗口 \newline % Row Count 6 (+ 1) O(1) \newline % Row Count 7 (+ 1) \seqsplit{O(M)-M为子窗口数适用大多数场景,可以通过调节采样子窗口数来平衡开销} \newline % Row Count 9 (+ 2) 漏桶 \newline % Row Count 10 (+ 1) O(1) \newline % Row Count 11 (+ 1) O(1) \newline % Row Count 12 (+ 1) \seqsplit{要求输出速率恒定的场景,能够平滑流量} \newline % Row Count 14 (+ 2) 令牌桶 \newline % Row Count 15 (+ 1) O(1) \newline % Row Count 16 (+ 1) O(1) \newline % Row Count 17 (+ 1) \seqsplit{与漏桶类似,区别在于允许一定的突发流量} \newline % Row Count 19 (+ 2) 滑动日志 \newline % Row Count 20 (+ 1) \seqsplit{O(log(N)-取决于O(N)-N为时间窗口内} \newline % Row Count 21 (+ 1) \seqsplit{要求完全精确的控制,保证任意T时刻内流量选择的数据结构允许的最大请求量} 不超过N,高时间和空间复杂度,性能最差% Row Count 25 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{common linux command}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{File and Directory Operations: \newline % Row Count 1 (+ 1) ls: List files and directories in the current directory. \newline % Row Count 3 (+ 2) cd: Change the current working directory. \newline % Row Count 4 (+ 1) pwd: Print the current working directory. \newline % Row Count 5 (+ 1) mkdir: Create a new directory. \newline % Row Count 6 (+ 1) touch: Create an empty file. \newline % Row Count 7 (+ 1) cp: Copy files or directories. \newline % Row Count 8 (+ 1) mv: Move or rename files or directories. \newline % Row Count 9 (+ 1) rm: Remove files or directories. \newline % Row Count 10 (+ 1) find: Search for files and directories. \newline % Row Count 11 (+ 1) grep: Search for patterns in text files. \newline % Row Count 12 (+ 1) File Viewing and Manipulation: \newline % Row Count 13 (+ 1) cat: Concatenate and display file contents. \newline % Row Count 14 (+ 1) less or more: View files one page at a time. \newline % Row Count 15 (+ 1) head and tail: Display the beginning or end of a file. \newline % Row Count 17 (+ 2) nano or vi/vim: Text editors for creating or editing files. \newline % Row Count 19 (+ 2) File Permissions: \newline % Row Count 20 (+ 1) chmod: Change file permissions. \newline % Row Count 21 (+ 1) chown: Change file ownership. \newline % Row Count 22 (+ 1) chgrp: Change file group ownership. \newline % Row Count 23 (+ 1) User and Group Management: \newline % Row Count 24 (+ 1) useradd: Add a new user. \newline % Row Count 25 (+ 1) userdel: Delete a user. \newline % Row Count 26 (+ 1) passwd: Change user password. \newline % Row Count 27 (+ 1) groupadd: Add a new group. \newline % Row Count 28 (+ 1) groupdel: Delete a group. \newline % Row Count 29 (+ 1) groups: List user's groups. \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{common linux command (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Process Management: \newline % Row Count 1 (+ 1) ps: List running processes. \newline % Row Count 2 (+ 1) top or htop: Real-time system monitoring tools. \newline % Row Count 3 (+ 1) kill: Terminate processes. \newline % Row Count 4 (+ 1) pkill and killall: Kill processes by name. \newline % Row Count 5 (+ 1) System Information: \newline % Row Count 6 (+ 1) uname: Display system information. \newline % Row Count 7 (+ 1) df: Display disk space usage. \newline % Row Count 8 (+ 1) free: Display memory usage. \newline % Row Count 9 (+ 1) uptime: Show system uptime. \newline % Row Count 10 (+ 1) lscpu and lshw: Display CPU and hardware information. \newline % Row Count 12 (+ 2) Package Management (Package-Based Distributions): \newline % Row Count 13 (+ 1) apt-get or apt: Advanced Package Tool for Debian-based systems (e.g., Ubuntu). \newline % Row Count 15 (+ 2) yum or dnf: Package manager for Red Hat-based systems (e.g., CentOS, Fedora). \newline % Row Count 17 (+ 2) Networking: \newline % Row Count 18 (+ 1) ifconfig or ip: Display network interface information. \newline % Row Count 20 (+ 2) ping: Send ICMP echo requests to a host. \newline % Row Count 21 (+ 1) netstat or ss: Display network statistics. \newline % Row Count 22 (+ 1) ssh: Securely connect to remote servers. \newline % Row Count 23 (+ 1) scp: Securely copy files between hosts. \newline % Row Count 24 (+ 1) File Compression and Archiving: \newline % Row Count 25 (+ 1) tar: Archive files and directories. \newline % Row Count 26 (+ 1) gzip or gunzip: Compress or decompress files. \newline % Row Count 27 (+ 1) zip and unzip: Create and extract ZIP archives. \newline % Row Count 28 (+ 1) File Transfer: \newline % Row Count 29 (+ 1) wget and curl: Download files from the internet. \newline % Row Count 30 (+ 1) } \tn \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{common linux command (cont)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{ftp or sftp: Transfer files to/from remote servers.% Row Count 2 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{In java, how to test private methods?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Reflection: While not recommended for production code, you can use Java's reflection API to access and invoke private methods for testing purposes. This allows you to bypass access restrictions and test the private methods directly. Here's an example of how you can use reflection to test a private method: \newline % Row Count 7 (+ 7) MyClass myClass = new MyClass(); \newline % Row Count 8 (+ 1) Method privateMethod = \seqsplit{MyClass.class.getDeclaredMethod("privateMethod"}, int.class, int.class); \newline % Row Count 11 (+ 3) \seqsplit{privateMethod.setAccessible(true);} // Allow access to private method \newline % Row Count 13 (+ 2) int result = (int) \seqsplit{privateMethod.invoke(myClass}, 3, 4); \newline % Row Count 15 (+ 2) \seqsplit{System.out.println(result);} // Output: 7 \newline % Row Count 16 (+ 1) \seqsplit{使用PowerMock测试私有方法:} \newline % Row Count 17 (+ 1) Object result = \seqsplit{Deencapsulation.invoke(mockClass}, methodName, parameter1, parameter2....)% Row Count 19 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{large amount of traffic}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{load balancer \newline % Row Count 1 (+ 1) rate-limit in api gateway \newline % Row Count 2 (+ 1) microservices auto-scale \newline % Row Count 3 (+ 1) Circuit Breaker Pattern Hystrix \newline % Row Count 4 (+ 1) whole-chain pressure test \newline % Row Count 5 (+ 1) sharding mysql \newline % Row Count 6 (+ 1) Monitoring and Alerts \newline % Row Count 7 (+ 1) redis cache cache warming \newline % Row Count 8 (+ 1) CDNs \newline % Row Count 9 (+ 1) Database Optimization \newline % Row Count 10 (+ 1) :% Row Count 11 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{how many transaction request are you getting}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{my teams's system should be around 2k qps \newline % Row Count 1 (+ 1) my user bebehavior tracking system should be around 500 qps.% Row Count 3 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{unit testing integration}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{Integration Testing in Java: \newline \newline Setup Testing Environment: Integration testing often requires setting up a test environment that resembles the production environment. This includes configuring databases, external services, and any other dependencies. \newline \newline Choose a Testing Approach: \newline \newline Embedded Containers: You can use embedded containers like Spring Boot's @SpringBootTest for testing Spring-based applications. These containers provide a controlled environment for integration testing. \newline Docker Containers: Another approach is to use Docker containers to spin up test versions of external services and databases. Tools like Testcontainers can help with this. \newline Write Integration Tests: Write test cases that focus on testing the interactions between different components or services. These tests typically cover scenarios like API calls, database operations, and messaging between components. \newline \newline java \newline Copy code \newline import \seqsplit{org.junit.jupiter.api.Test;} \newline import \seqsplit{org.springframework.beans.factory.annotation.Autowired;} \newline import \seqsplit{org.springframework.boot.test.context.SpringBootTest;} \newline import \seqsplit{org.springframework.boot.test.web.client.TestRestTemplate;} \newline import \seqsplit{org.springframework.boot.web.server.LocalServerPort;} \newline \newline @SpringBootTest(webEnvironment = \seqsplit{SpringBootTest.WebEnvironment.RANDOM\_PORT)} \newline public class MyIntegrationTest \{ \newline \newline @LocalServerPort \newline private int port; \newline \newline @Autowired \newline private TestRestTemplate restTemplate; \newline \newline @Test \newline public void testApiEndpoint() \{ \newline String url = "http://localhost:" + port + "/api/some-endpoint"; \newline String response = \seqsplit{restTemplate.getForObject(url}, String.class); \newline // Perform assertions on the response \newline \} \newline \} \newline Run Integration Tests: Similar to unit tests, use your build tool or IDE to run integration tests. Integration tests may take longer to execute than unit tests because they often involve external dependencies. \newline \newline Clean Up: Ensure that your tests clean up any resources or data created during testing to leave the environment in a clean state.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{asynchronized API features in Java?}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{CompletableFuture: asynchronous tasks, combining them, and handling their results or exceptions using a fluent API. \newline % Row Count 3 (+ 3) Async Servlets: This allows your web server to handle more requests with fewer threads, improving scalability. \newline % Row Count 6 (+ 3) Java NIO (New I/O) \newline % Row Count 7 (+ 1) Java Concurrency Utilities: JUC CountDownLatch \seqsplit{单线程等待其他线程做统计,CyclicBarrier} \seqsplit{多线程等待,semaphore} \newline % Row Count 10 (+ 3) Reactive Programming: Libraries like Reactor and RxJava enable reactive programming \newline % Row Count 12 (+ 2) Java 9+ CompletableFuture Enhancements: combining multiple futures, dealing with timeouts% Row Count 14 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{self introduction}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{Hi, my name is Andrew. I am a java backend engineer with 5 years experience. \newline % Row Count 2 (+ 2) I am specilized in developing scalable and reliable applications using Java, Spring Framework, MySQL, Redis, Kafka and etc. \newline % Row Count 5 (+ 3) My last job is in QTrade, it's a company doing the business of helping financial companies with compliance. \newline % Row Count 8 (+ 3) My team is the infrastructure team. My responsibility is solving online issues and optimizing system. Building some middleware like Canal to symchronize data from MySQL to Redis and ElasticSearch. Building some basic system like user behavior tracking and reporting system. \newline % Row Count 14 (+ 6) Before QTrade, I worked in SF Technology. In SF technology, I was in the SF mini program team. My responsibility is developing new features and functions for SF mini program. SF mini program is a popular built-in 3rd-party app which has around 200 thousand qps. \newline % Row Count 20 (+ 6) I apply to this position because I have huge interest in Japanese culture. When I was a child, I watched a lot of Japanese cartoons. And I learned some basic Japanese before. Rakuten is an international company with multi-culture. Its tech stack is almost the same as I am using. \newline % Row Count 26 (+ 6) Thank you. That's the whole introduction about myself as a 5-years java backend engineer.% Row Count 28 (+ 2) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{day to day activities \& contribution to the team}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{monring stand up to follow up the shedule, talk about potential issues \newline % Row Count 2 (+ 2) if there's urgent online issues ,will solve it first \newline % Row Count 4 (+ 2) communicate the details of the requirement with product manager, finish the code part , self test , write api documentation, communicate with frontend engineer, as scheduled which in agile it's called spur \newline % Row Count 9 (+ 5) before release the production version, there will be code review \newline % Row Count 11 (+ 2) contributions: solve online issues and optimize the system, build some middleware, guide some junior engieers% Row Count 14 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{question time}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{what is a work day like in this team? \newline % Row Count 1 (+ 1) what are the tech stacks that the team is currently using? \newline % Row Count 3 (+ 2) what difficulty and challenge the team is facing? \newline % Row Count 4 (+ 1) what's the manager's plan for me to do? \newline % Row Count 5 (+ 1) what do I need to learn in advance?% Row Count 6 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{question time (copy)}} \tn \SetRowColor{white} \mymulticolumn{1}{x{5.377cm}}{what is a work day like in this team? \newline % Row Count 1 (+ 1) what are the tech stacks that the team is currently using? \newline % Row Count 3 (+ 2) what difficulty and challenge the team is facing? \newline % Row Count 4 (+ 1) what's the manager's plan for me to do?% Row Count 5 (+ 1) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}