IT 61

nginx로 로드밸런싱 설정하기

nodejs에서 클러스터 모듈을 사용하면 싱글 프로세스로 동작하는 노드를 cpu 코어 모두 사용할 수 있도록 구현할 수 있습니다. 이를 활용하여 자신의 CPU 코어 수를 고려하여 서버를 몇 개 띄울 수 있을지 결정할 수 있습니다. 그렇다면 여러 개의 서버를 띄었을 경우, 도메인 하나에 어떻게 매핑할 수 있을까요? 바로 nginx를 이용하여 로드밸런싱을 설정할 수 있습니다. nginx 로드밸런싱 설정 방법 #http블럭 내부에 추가 #NodeJS 서버 로드밸런싱 upstream nodejs_server { #least_conn; #ip_hash; server localhost:3000; server localhost:3001; } #3333번 포트 NodeJS 서버로 연결 server{ listen 333..

IT/web, hosting 2023.12.13

[MariaDB] Maxscale Replication With Docker

DB 이중화를 하면서 아래와 같은 이슈 때문에 애를 먹었습니다.◞‸◟ [ERROR] Slave I/O: error connecting to master 'usr_repl@192.168.5.138:3306' - retry-time: 10 maximum-retries: 100000 message: Can't connect to server on '192.168.5.138' (110 "Connection timed out"), Internal MariaDB error code: 2003 여러번 시도 해보니깐, 도커 포트 포워딩을 할 때 host port number를 mariadb 서비스 port number인 3306이 아닌 다른 임의의 port number로 지정했더니 잘 동작했습니다. 1. MariaDB..

IT/mariadb 2023.09.22

[acmicpc] 16933. 벽 부수고 이동하기 3(python)

2차원 배열을 사용하여 구현하였습니다. 벽 부수고 이동하기 2 : https://seyeon-hello.tistory.com/62 import sys from collections import deque input=sys.stdin.readline N,M,K=map(int,input().split()) arr=[list(map(int,input().strip())) for _ in range(N)] dirs=[(1,0),(0,1),(-1,0),(0,-1)] q=deque() q.append((0,0,0,1,1)) #가로,세로,벽,이동,낮 visit=[[sys.maxsize]*M for _ in range(N)] visit[0][0]=0 def bfs(): while q: r,c,cnt,move,day=q..

IT/coding study 2023.08.22

[acmicpc] 14442. 벽 부수고 이동하기 2(python)

3차원 배열을 사용 안하는 방법으로 구현하였습니다. 아래 블로그를 참고했습니다. https://hongjw1938.tistory.com/163 import sys from collections import deque input=sys.stdin.readline n,m,k=map(int,input().split()) arr=[list(map(int,input().strip())) for _ in range(n)] dirs=[(1,0),(0,1),(-1,0),(0,-1)] visit=[[sys.maxsize for _ in range(m)] for _ in range(n)] q=deque() q.append((0,0,0,1)) visit[0][0]=1 answer=-1 while q: r,c,cnt,move..

IT/coding study 2023.08.12

[acmicpc] 13913. 숨바꼭질 4(python)

리스트에 방문했던 위치를 계속 누적했을 경우 메모리초과가 나와서, 딕셔너리를 통해 해당 위치의 전 위치를 저장하는 방법으로 구현하였습니다. import sys from collections import deque, defaultdict input=sys.stdin.readline N,K=map(int,input().split()) visit=[0]*100001 q=deque() dicts=defaultdict(int) q.append(N) while q: num=q.popleft() if num==K: print(visit[num]) answer=[] while num!=N: answer.append(num) num=dicts[num] answer.append(N) answer.reverse() prin..

IT/coding study 2023.03.28

[acmicpc] 1938. 통나무 옮기기(python)

필자는 통나무 모든 좌표를 방문체크를 했는데, 타 블로그 코드들을 확인해보니 중심좌표만 방문체크를 하고 있었다. 이 점을 개선해나가면 좋을 것 같다. import sys from collections import deque input=sys.stdin.readline N=int(input()) board=[list(input().strip()) for _ in range(N)] visit=[[[0]*2 for _ in range(N)] for _ in range(N)] dirs=[(1,0),(0,1),(-1,0),(0,-1),[(1,0),(0,0),(-1,0)],[(0,1),(0,0),(0,-1)]] slog=[] dlog=[] for r in range(N): for c in range(N): if b..

IT/coding study 2023.03.05