---
# System prepended metadata

title: Amazon
tags: [interview prep]

---

# 面试问题

## 自我介绍
Hi，my name is Lexi. Currently I am a first-year master student majoring in computer and information science at Cornell Tech at Cornell University. I got my Bachelor of Science Degree on Information Studies at Syracuse University. 
+ 为什么选择这个行业
    * My tech journey started back in my freshman year as a physics student. I did a running light program on a microcontroller. When I was watching those lights illuminate one by one, I feel a sense of achievement and satisfaction. This experience made me captivated with programming and decide to choose programming as my life career, leading me to delve deeper into software engineering. I really love this industry because it combines my love for problem-solving and innovation. 
+ 1-2句 overall internship experience
    * As for my internships, at Famulei.us and Apexus Tech, they were really where I put all that passion into action. At Famulei.us, I worked as a Backend Developer Intern. I built RESTful APIs for their e-commerce platform using Java, Springboot and MySql with the integration of AWS services. Prior to that role, I was at Apexus Tech where I helped shift some features from monolithic to a microservice setup. 
+ ==> 我很契合
    + Based on my these experience, I am quite confident that I can fit into the team at your company and start to contribute my value quickly. 

## 项目介绍
Famulei.us
+ 1.这个项目是做什么的，这个网站（ecommerce)是干什么的
    + At Famulei.us, as a Backend Developer Intern, I developed scalable RESTful APIs for an E-commerce platform which consists of core modules such as user management, product management, shopping cart, payment, and order management and so on.  

+ 2.分成两部分 （tech stack + 我做了什么）
    + I was mainly working on backend. To build these functions, I mainly used java, Spring Boot, MySQL, with the integration of AWS services to ensure the efficient operation and the scalability of the platform.
    + (我做了什么) I implemented SQS, Redis and JWT to improve the performance of the platform. Besides, I proposed and made a Chatbot demo based on chatgpt which can significantly reduce the query of customer service and operational costs. 
    + (总结) This experience not only gave me insight into the back-end development of e-commerce platforms, but also enhanced my technical skills and gave me a deeper understanding of modern software development and cloud computing services.

+ 如果还问我，我就参与了user management 的开发，functions and endpoints
    + reset password endpoint, enhancing the user experience and security. 
    + use SQS to facilitate async file upload, which reduces wait time and improves the user experience on the platform. 
    + use redis to store user profile
        + I employed Redis for efficient and fast retrieval of user profile data, significantly reducing the load on our primary database. 
    + use jwt to Secure Authentication. 
        + Stateless authentication often reduces the need for database lookups or session data verification with every request. 
    + Optimize SQL Query
        + Generally speaking we can use tools like "EXPLAIN, TRACE, SHOW PROFILE，SLOW Query Log" 这种来
        + 使用 LIKE %pattern% 不能使用索引。使用 pattern% 就可以
        + 场景是search user by name

    + 我有个ticket: 
        + customer service接电话的时候，抱怨查user很慢
        + I was asked to solve this problem. 
        + => scan the whole table --> use index
        + => introduce cache （Redis） 存user profile，然后我们先去user profile查。

接线员们面临着一个棘手的问题：每当他们尝试查找look up用户信息时，系统的响应速度异常缓慢。这不仅影响(lower)了工作效率，还导致客户等待时间过长 result in a long waiting time of our customer，从而引起了客户的抱怨。

I was assigned to solve this problem. I deeply analyze the query system, and found the main problem (查全表 instead of using index)
- I introduced the index searching. 

其次，我决定introduce cache mechanism and I choose redis as our solution to store user profile. When the user login, its profile would be put into redis. When there is query request, the system will check redis first, and then check the database. By introducing Cache, the access requests toward database become fewer. 
* This not only further reduces query time, but also greatly reduces the strain on the database.

* The effect of these two changes are immediate, and our customer service can access the information of our user quickly. 
* By this project, I not only solve a problem that has been plaguing my team for a long time, but also improve our customer service quality a lot. These are the reasons why I think this is one of the proudest project of this internship. 



第二个项目 Apexus Tech

+ 1.这个项目是做什么的，这个网站是干什么的
    + During my internship at Apexus Tech, I worked as a software engineer intern and I helped to migrate services from monolithic to microservice for a financial services application. This project aimed to use nlp technologies to analyze web text data, calcuate the sentiment scores of the stocks and display them through a visual dashboard. 
+ 2. 分成两部分 （tech stack + 我做了什么）
    + At that time I also work on backend using Java, Spring Boot, PostgreSQL. 
    + My focus was on user management module and ensuring robust backend functionality. 
    + I developed multiple functions and endpoints, ensuring our system can process the user data efficiently. (User Login and Out)
    + Also, I took care of both the unit test and the integration test to ensure the reliability and the stability. My pursurance on rigorous testing helped in maintianing high quality of our software products.
    + An exciting aspect of my internship was the opportunity to shadow the deployment process of our microservices. This experience provided me with valuable insights into CI/CD practices, enhancing my understanding of modern software deployment strategies. 


Tech  - Spring Boot 相关的
我create了几个endpoints, **sign-in and out, update user profile, reset user password**(填一个邮箱，会给一个一次性的url给他发到邮箱里，然后在他改的时候，update他的password)

## Deploy Springboot APP

1. 写Dockerfile打包应用，构建Docker Image
2. Push代码到GitHub上
3. Create AWS Code Pipeline: 
    * I use cloudformation to do so. 
    * I would setup the following stages. 
        * Source Stage to supervise the code change in my git repo. 
        * Build Stage: use AWS Code Build to build docker image. ==> Image Store in ECR
        * Deployment Stage: I would set up deloyment movement. 

Launch Code Pipeline

4. codepipeline会detect到github更新
5. build and push docker image 到Amazon Elastic Container Registry （ECR)
6. and then deploy the corresponding container to ECS Elastic Container Service. 


-----------
QPS -- 如果说到数据库相关的
* 要回答的不是具体的数字，而是

user - login - 访问一次数据库，1天有5000个user去login -- 

* 我们日活用户可能就是5k，然meim
Redis
PostgreSQL

遇到的挑战/困难。如何解决？
你在团队中扮演什么样的角色，
在这个项目中， 你学到了什么？技术方面/team work/沟通技巧
最满意/最不满意的地方
你对你自己的代码质量如何评价？为什么这么评价？好的地方/不好的地方是什么？如何改进

Famulei.us
RESTful api 设计问题， 比如http methods/url convention
ChatGPT
* 使用的是哪个model？
    - GPT 3.5- turbo
使用了openai的哪些api？
    * No API for Java, so we use http response directly
```java
@Service
public class ChatGPTService {

    private final String apiEndpoint = "https://api.openai.com/v1/engines/gpt-3.5-turbo/completions";

    @Value("${openai.apikey}")
    private String apiKey; // See application-dev.properties

    public String getResponse(String prompt) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();

        String requestBody = buildRequestBody(prompt);

        HttpEntity<String> entity = new HttpEntity<>(requestBody, headers);
        return restTemplate.postForObject(apiEndpoint, entity, String.class);
    }

    /**
     * 在buildRequestBody方法中，您需要构建包含prompt和其他参数（如温度、最大令牌数等）的JSON请求体。
     * @param prompt
     * @return
     */
    private String buildRequestBody(String prompt) {
        // Build JSON Request Body Here
        // Include parameters like temperature, max tokens etc.
        return "{...}";
    }
```

**遇到了哪些问题？**

rate limiting之类
* 有两种，超出任意一种就算超。
* ![Screenshot 2023-11-23 at 7.31.02 PM](https://hackmd.io/_uploads/H1ECRDTE6.png)

对于develop环境来说，超不了。
![Screenshot 2023-11-23 at 7.32.13 PM](https://hackmd.io/_uploads/rksGkd64p.png)

当超过这些限制时，API服务通常会返回错误消息，如HTTP 429错误（Too Many Requests），提示你已经超过了速率限制。这时，你需要减少请求频率或令牌使用，直到不再超过限制为止。

**openai的费用比较高，你们使用了什么方面降低开销？**
**Comprehensive FQA: if it can be related to a FQA **

**"用户打算去法国旅游，需要电话卡。FQA信息：我们提供多种电话卡，适合不同的旅游需求。用户子问题1：推荐一张适合法国使用的电话卡。FQA信息：我们的X型号电话卡在法国提供优惠的数据套餐。用户子问题2：需要好的数据套餐。FQA信息：X型号电话卡提供多种数据套餐选项，可根据需求选择。用户子问题3：关于漫游费用的信息。FQA信息：在欧洲多国，包括法国，X型号电话卡漫游费用优惠。"**

4 cents every 1 hundred thousand token. 

每个user只能和chatbot聊20个来回，更多的就让它接入人工客服了。

openai的费用比较高，你们使用了什么方面降低开销？
把embedding好的东西发给它。

----




AWS
用到了哪些服务？ 为什么用这些服务
S3, ECS, RDS, SQS, CodePipeline

为什么用SQS
1. 异步处理文件上传：我们会要求user上传一些身份证明的照片or文件，用户上传文件后，这些文件可以被放入队列中，然后由后台服务逐一处理，不会影响用户体验。

为什么使用RDS 而不是用 Nosql
为什么用Redis保存cache， 为什么不用memory
gitflow的工作流程
swagger的优势是什么
Apexus Tech
Springboot
transaction 相关 isolation propagation
一些annotation 问题，比如 RestController, GetMapping和requestMappting的区别
PostgreSQL 和 Mysql的区别
介绍一下JWT
monolithic to microservice 过程中遇到过哪些问题？ 如何解决

Redis: store user profile, Add profile when user login.


