Gitlab instance becomes unresponsive and returns 502 errors in web ui and during api calls

Summary

Steps to reproduce

mostly like in #3222 (closed)

What is the current bug behavior?

after multiple api calls (for example, for each project get list of branches), api calls start to return 502. Web ui does not work either.

What is the expected correct behavior?

Working web ui and api.

Relevant logs

Relevant logs unicorn strace as per request in #3222 (closed)

Details of package version

Provide the package version installation details

official gitlab-ce docker image with gitlab 11.5.3 (aa11737)

Environment details

  • Operating System: Ubuntu 17.10 + docker 18.03.0-ce, build 0520e24
  • Installation Target, remove incorrect values:
    • Bare Metal Machine + docker
  • Installation Type, remove incorrect values:
    • New Installation
    • Upgrade from version 11.5.1
  • Is there any other software running on the machine: yes, in separate containers
  • Is this a single or multiple node installation? single node
  • Resources
    • CPU: Intel(R) Xeon(R) CPU E5440 @ 2.83GHz (8 cores)
    • Memory total: 32 Gb

Configuration details

Provide the relevant sections of `/etc/gitlab/gitlab.rb`
GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://xxx'
        registry_external_url 'https://hub.xxx'
        mattermost_external_url 'https://chat.xxx'
        mattermost_nginx['enable'] = false
        mattermost['service_address'] = '0.0.0.0'
        mattermost['gitlab_enable'] = true
        mattermost['gitlab_id'] = "xxx"
        mattermost['gitlab_secret'] = "xxx"
        mattermost['gitlab_scope'] = ""
        mattermost['gitlab_auth_endpoint'] = "https://xxx/oauth/authorize"
        mattermost['gitlab_token_endpoint'] = "https://xxx/oauth/token"
        mattermost['gitlab_user_api_endpoint'] = "https://xxx/api/v4/user"
    nginx['enable'] = false
    unicorn['worker_timeout'] = 3600
    unicorn['worker_processes'] = 6
    gitlab_rails['trusted_proxies'] = ['172.18.0.0/16']
    gitlab_workhorse['listen_network'] = "tcp"
    gitlab_workhorse['listen_addr'] = "0.0.0.0:8181"

    registry_nginx['enable'] = false
    registry['registry_http_addr'] = '0.0.0.0:5000'

    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp-relay.infrastructure_front"
    gitlab_rails['smtp_port'] = 2525
    gitlab_rails['smtp_domain'] = "xxx"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

    gitlab_rails['time_zone'] = 'Europe/Moscow'

    gitlab_rails['gitlab_email_from'] = 'xxx'
    gitlab_rails['gitlab_email_reply_to'] = 'xxx'