본문 바로가기

728x90
반응형

전체 글

(256)
git&github: 내 최근 커밋 위에 pull request 올려서 테스트 (머지 X, rebase 활용하기) 1. pr의 커밋들을 fetch # git fetch upstream pull/PR_ID/head:BRANCH_NAME $ git fetch upstream pull/387/head:pr-387 위와 같이 하면 pr-387이라는 branch가 생기고, 해당 branch에 id 387의 pr이 받아진다. 2. 내 커밋들을 base로 하기 1) pr을 받은 branch(pr-387)로 이동 # git checkout BRANCH_NAME $ git checkout pr-387 2) 내가 base로 하기를 원하는 branch를 rebase한다 # git rebase MY_BRANCH $ git rebase master
SQLAlchemy: db pool 관리 DB connection pool from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker engine = create_engine( self._url, poolclass=QueuePool, pool_size=20, max_overflow=40, pool_timeout=70, pool_recycle=60, ) poolclass - 어떠한 connection pool을 사용할지에 대한 옵션 일반적으로 QueuePool을 사용하며, 옵션에 별도 명시하지 않을 경우 default 값이기도 하다. QueuePool - 재사용 가능한 pool 사용 - 다수의 동시적인 connection 허용 (multiple concurrent da..
Linux: 가상환경 메모리 설정 메모리를 적게해서 부하테스트를 하는 방법을 알아보니, ulimit 이라는 방법이 있다. $ ulimit -v 200000 위와 같은 식으로 하면 현재 사용하는 shell의 memory가 200000kb로 설정된다. 해당 쉘과, 자식 프로세스에만 영향을 미치고, 쉘을 껐다 키면 변경 전 상태로 다시 돌아간다. 일시적이 아니라 아예 설정값을 바꾸려면 .bashrc 등에 위의 명령어를 기재하면 된다. 도커 이미지를 만들어서 메모리와 cpu 값을 정해서 하는 방법도 있지만, 간단하게 테스트 할 때는 ulimit을 사용하는 것이 편하다.
Python: 서버 부하테스트 - locust python script로 간단하게 서버 부하테스트를 할 수 있는 library 사용법이 간단하고, 브라우저를 통해 분석 그래프까지 제공해준다. 설치: pip install locust locustfile.py 작성 from locust import HttpUser, task, between class WebsiteUser(HttpUser): wait_time = between(1, 5) @task def load_test(self): self.client.get("/your-endpoint") 테스트할 서버를 실행시키고, locust도 함께 실행시켜주자 locust는 기본적으로 8089 포트로 연결된다. 나는 fastapi 서버를 실행시키고 있고, fastapi는 기본적으로 8000포트로 열린다. fa..
git hook: 특정 명령어 금지 시키기 .git/hooks 디렉토리에 pre-push를 만들어서 git push 명령어 전에 다음 로직을 선행시켜서 git push upstream master를 막아보자 $ cd .git/hooks $ nano pre-push 아래 스크립트 작성 #!/bin/sh remote="$1" while read local_ref local_sha remote_ref remote_sha do if [ "$remote" = "upstream" ] && [ "$remote_ref" = "refs/heads/master" ]; then echo "Pushing to upstream master is prohibited." exit 1 fi done exit 0 pre-push 실행권한 주기 $ chmod +x pre-push
git remote 관리 git remote 이름 정해서 url 추가 git remote add remote 이름 변경 git remote rename remote 삭제 git remote remove remote url 변경 git remote set-url
request.scope vs request.headers in FastAPI # ChatGPT Q. in Python FastAPI, How can I see the request user's prefix whethere http or https? A. In FastAPI, you can determine whether a request uses HTTP or HTTPS by inspecting the request object. The request object contains various information about the incoming HTTP request, including the scheme which indicates whether the request was made using HTTP or HTTPS. To access the request object in FastAPI,..
MySQL: query log 확인 # table & file OS: ubuntu 22.04 기준 1. my.cnf 설정파일 변경 /etc/mysql/my.cnf 또는 /etc/my.cnf 나는 /etc/mysql/my.cnf에 있었음 아래 설정을 추가한다 더보기 [mysqld] general_log = 1 general_log_file = /path/to/your/logfile.log 로그 파일 대신에 테이블을 생성해서 볼수도 있다. general_log_file 대신에 log_output = TABLE 이용 더보기 [mysqld] general_log = 1 general_log_file = /path/to/your/logfile.log -> mysql database안에 general_log 테이블 생성됨. 여기에 모든 로그가 기록된다. 사이즈 관리 유의 my..

728x90
반응형