이오이오이오
코딩하는헬린이
이오이오이오
전체 방문자
오늘
어제
  • 분류 전체보기 (39)
    • 기타 (2)
      • 잡다한 (2)
      • 헬스 (0)
    • 개발 (21)
      • Sql (3)
      • Java (2)
      • Spring (8)
      • OAuth (4)
      • node.js (1)
      • AWS (1)
      • Linux (2)
    • 이론 (11)
    • Dev Tool (1)
      • IntelliJ IDEA (1)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 로이필링
  • restfulapi
  • 블록체인지갑
  • pos
  • db 성질
  • 카카오로그인
  • oauth
  • springboot
  • blockchain
  • bip
  • Ipfs
  • java
  • isolation level
  • Spring Boot
  • RESTful
  • nft
  • 니모닉
  • Spring
  • POW
  • reactive streams
  • webflux
  • 블록체인
  • kakaologin

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
이오이오이오

코딩하는헬린이

개발/Spring

[Spring] poi 병목현상 해결!

2020. 11. 12. 13:28
반응형

안녕하세요 

 

row 생성시 퍼포먼스가 안나와 찾아봐서 포스팅합니다.

 

 

저 같은 경우 poi를 이용하여 엑셀 생성시 1000건 2000건 뿐인데 퍼포먼스가 안나왔으며

 

로컬에서 실행시 다운로드는 되지만 최소 4분 배포 후 테스트 시 timeout 에러가 나왔습니다.

 

각 시트에 autoSizeColumn 메소드를 사용해 조정을 한게 원인이었으며

 

 

ex)

  // 데이터 부분 생성
    for(Map<String, Object> vo : deliverList) {
         row = sheet.createRow(rowNo++);
         row.setHeight((short)512);
      sheet.autoSizeColumn(0);
      sheet.setColumnWidth(0,(sheet.getColumnWidth(0)));
         cell = row.createCell(0);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("BILL_NO").toString());
        
      sheet.autoSizeColumn(1);
      sheet.setColumnWidth(1,(sheet.getColumnWidth(1)));
         cell = row.createCell(1);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("NAME").toString().replaceAll("-", ""));
        
        
      sheet.autoSizeColumn(2);                                                                                                          //
      sheet.setColumnWidth(2,(sheet.getColumnWidth(3)));   
         cell = row.createCell(2);
         cell.setCellStyle(cellStyle);
         cell.setCellValue(vo.get("AGE").toString().equals(" ") ? "" : vo.get("WECHAT_ID").toString());
               
        
      sheet.autoSizeColumn(3);                                                                                                          //
      sheet.setColumnWidth(3,(sheet.getColumnWidth(3)));    //다운로시 NVL null 치환 후 빈값으로 처리하여 처리
         cell = row.createCell(3);                                                                                                        
         cell.setCellStyle(cellStyle);                          //다운로드시 Null값이 존재 시 에러발생함
         cell.setCellValue(vo.get("ADDRESS").toString().equals(" ") ? "" : vo.get("CUST_NM_ENG").toString());
         //
         cell = row.createCell(4);                                                                                                         //
         cell.setCellStyle(bodyStyle);                                                                                                     //
         cell.setCellValue(vo.get("NUMBER").toString()); 
         //
      sheet.autoSizeColumn(5);                                                                                                          //
      sheet.setColumnWidth(5,(sheet.getColumnWidth(5)));                                                                                //
         cell = row.createCell(5);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("PASS_NO").toString());
  }

 

 

수정후 

  // 데이터 부분 생성
    for(int i = 0; i < deliverList.size(); i++) {
    	 Map<String, Object> vo = deliverList.get(i);
         row = sheet.createRow(rowNo++);
         row.setHeight((short)512);
         sheet.autoSizeColumn(i);
         sheet.setColumnWidth(i,(sheet.getColumnWidth(0)));
         cell = row.createCell(0);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("BILL_NO").toString());
        
         cell = row.createCell(1);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("NAME").toString().replaceAll("-", ""));
        
         cell = row.createCell(2);
         cell.setCellStyle(cellStyle);
         cell.setCellValue(vo.get("AGE").toString().equals(" ") ? "" : vo.get("WECHAT_ID").toString());
                    
         cell = row.createCell(3);                                                                                                        
         cell.setCellStyle(cellStyle);  
         cell.setCellValue(vo.get("ADDRESS").toString().equals(" ") ? "" : vo.get("CUST_NM_ENG").toString());
         
         cell = row.createCell(4);                                                                                                         //
         cell.setCellStyle(bodyStyle);                                                                                                     //
         cell.setCellValue(vo.get("NUMBER").toString()); 
                                                                        //
         cell = row.createCell(5);
         cell.setCellStyle(bodyStyle);
         cell.setCellValue(vo.get("PASS_NO").toString());
  }

 

 

병목 현상이 생긴다면 참고 바랍니다.

 

감사합니다.

 

참고 : stackoverrun.com/ko/q/5635971

        stackoverrun.com/ko/q/6400822

반응형

'개발 > Spring' 카테고리의 다른 글

[Spring] apple client_secret (JWT) 생성  (0) 2022.09.01
[Spring boot] embedded mongodb replica 설정  (0) 2022.02.09
[Spring] poi를 이용한 excel 다운로드  (0) 2020.11.06
[Spring] 파일 정보를 못가져오는 에러! MultipartFile에 Xss Filter적용  (0) 2020.10.30
[Spring] 스프링부트 시큐리티를 이용한 로그인!  (0) 2020.10.19
    '개발/Spring' 카테고리의 다른 글
    • [Spring] apple client_secret (JWT) 생성
    • [Spring boot] embedded mongodb replica 설정
    • [Spring] poi를 이용한 excel 다운로드
    • [Spring] 파일 정보를 못가져오는 에러! MultipartFile에 Xss Filter적용
    이오이오이오
    이오이오이오

    티스토리툴바