반응형

Azure web app service를 통해 Python Flask api 앱 배포 시 발생한 문제

웹 페이지에서 해당 api 첫 호출 시 Load 시간이 너무 오래 걸리는 문제가 있었다.

 

해당 원인에 대해 검색하여 찾아보니 Windows Azure 웹 사이트 또는 앱의 경우 설정 된 어느 정도의 시간 동안 호출이 없을 시

비활성 상태로 전환되어지며 해당 상태에서 호출 시 다시 리소스 할당 및 구성을 진행하기 때문에 첫 연결 시간이 엄청 오래 걸릴수 있다고 한다.

 

해당 현상 해결방법

1. Azure portal > 앱 서비스 > 설정 > 구성 > 일반 설정 > 항상 설정됨 (Always On) 설정

https://stackoverflow.com/questions/51391197/azure-web-app-very-slow-after-publish-or-restart

 

Azure web app very slow after publish or restart

When I publish or restart my web app it loads very slowly the first time, then when I refresh with F5 it is ok again. what could it be?

stackoverflow.com

2. 특정 시간 간격으로 해당 앱 서비스를 호출하는 배치를 만든다.

 

위 문제를 처음 직면했을 때 어떤 이유인지 몰라 앱 로직을 다시 확인하고 DB 연결 시간 또는 검색 시간 등 여러가지 원인을 파악했을 때 정확한 원인 파악이 안되었다. 구글 검색을 성능 문제가 아닌 첫 연결에 대한 검색으로 해결법을 찾을 수 있었다..ㅠㅠ

다시보면 별거 아니였지만 꽤 고생한 문제

반응형

'Azure' 카테고리의 다른 글

[Azure] Resource group could not be found  (0) 2021.05.18
반응형

Python Flask api 앱을 만드는 도중 marshal_with 와 fields 라이브러를 이용해

output 데이터 타입을 설정할 떄 찾은 팁 공유

 

아래와 같이 사용하면 특정한 타입으로 응답필드 값을 설정하여 사용할 수 있다.

from flask_restful import fields

class MyDateFormat(fields.Raw):
    def format(self, value):
        return value.strftime('%Y-%m-%d')

resource_fields = {
    'id': fields.Integer,
    'date': MyDateFormat
}

참조

https://stackoverflow.com/questions/65982519/custom-date-format-for-flask-restful-fields-datetime-for-marshal-with

 

Custom date format for flask_restful fields.DateTime for marshal_with

I am using flask_restful's fields and marshal_with to serialize my APIs output data. But I am having problems with my date format. I am storing the date as an SQLAlchemy DateTime type, for example,...

stackoverflow.com

https://flask-restplus.readthedocs.io/en/stable/marshalling.html

 

Response marshalling — Flask-RESTPlus 0.13.0 documentation

Response marshalling Flask-RESTPlus provides an easy way to control what data you actually render in your response or expect as in input payload. With the fields module, you can use whatever objects (ORM models/custom classes/etc.) you want in your resourc

flask-restplus.readthedocs.io

 

반응형

'프로그래밍 > Python' 카테고리의 다른 글

[Python]sqlalchemy 사용법  (0) 2022.12.07
[PYTHON] 파이썬 함수 매개변수  (0) 2022.08.11
Single Linked list 구현  (0) 2018.03.22
창원시 버스 API 사용하기  (1) 2016.02.22
반응형

https://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/

 

React Lifecycle Methods diagram

Fully interactive and accessible React Lifecycle Methods diagram.

projects.wojtekmaj.pl

리액트 생명주기 관련 다이어그램

반응형

+ Recent posts