apache - Server lagging - Django + mongodb + cronjob -


i'm deploying django application, i'm using apache deployement module wgsi , mongodb database.

i got multiple cronjob called every 10min collect data many api (using django-kronos).

when server launch every thing great after few hours server start lagging , down. 100% of cpu used. here:

this 1 of crontask:

@kronos.register('*/10+2 * * * *') def update_mongo():   # init instagram api   api = instagramapi(client_id = 'social_auth_instagram_key',     client_secret = 'social_auth_instagram_secret')    # last post added in database   try:     last_id = post.objects(keywords = 'news').order_by('-created_at').limit(1)[0].insta_id   except:     last_id = 0    # last media tagged news   if last_id != 0:     results = api.tag_recent_media(tag_name = 'news', min_tag_id = last_id)   else:     results = api.tag_recent_media(tag_name = 'news')    result in results:     # if post doesn't exist, create new 1     try:       post = post.objects.get(insta_id = result.id)     except:       post = instapost()      # init post , save in database     post.save(result) 

the problem if don't know problem, apache + django ? or line post = post.objects.get(insta_id = result.id) ?

edit

i removed cronjob , same problem, after while physical memory , cpu explosed , server start lagging hard.

the server staging 1 bad 1 : 1 core, 992 mb ram

your charts show memory, disk , cpu activity around time application slows down. because of memory consumption inside application. when application hits memory limit start swapping disk. post chart of swapfile usage?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -