title: Live Streaming approach to avoid delay on viewer side
body: <p>I am trying to achieve live streaming. Operating system is iOS, Server side language is Swift with vapor framework, HTTP/2 protocol.
  Server configuration: Shared CPU, 1 vCPU, 2 GB RAM, 50 GB  SSD</p>
  <p>I am creating the fragmented mp4 segments on iOS device and uploading to server, one segment duration is 4 seconds and maximum size could be around 300kb.</p>
  <p>Code related to Segments:</p>
  <p>outputFileTypeProfile - AVFileTypeProfile.mpeg4AppleHLS</p>
  <pre><code>func assetWriter(_ writer: AVAssetWriter, didOutputSegmentData segmentData: Data, segmentType: AVAssetSegmentType, segmentReport: AVAssetSegmentReport?)
       {}
  </code></pre>
  <p>Audio/Video Encoder Configuration:</p>
  <pre><code>let audioCompressionSettings: [String: Any] = [
          AVFormatIDKey: kAudioFormatMPEG4AAC,
          // For simplicity, hard-code a common sample rate.
          // For a production use case, modify this as necessary to get the desired results given the source content.
          AVSampleRateKey: 44_100,
          AVNumberOfChannelsKey: 2,
          AVEncoderBitRateKey: 64_000
      ]
   
      let videoCompressionSettings: [String: Any] = [
          AVVideoCodecKey: AVVideoCodecType.h264,
          // For simplicity, assume 16:9 aspect ratio.
          // For a production use case, modify this as necessary to match the source content.
          AVVideoWidthKey: 504,
          AVVideoHeightKey: 896,
          AVVideoCompressionPropertiesKey: [
             // AVVideoExpectedSourceFrameRateKey : 30,
           //   AVVideoMaxKeyFrameIntervalKey:30,
              kVTCompressionPropertyKey_AverageBitRate: 500 * 1000,
          //    kVTCompressionPropertyKey_ProfileLevel: kVTProfileLevel_H264_High_AutoLevel
          ]
      ]
  </code></pre>
  <p>Is this the right approach to achieve live streaming or not? Because I am facing delay on viewer side.</p>
  <p>I am not using CDN or any caching technique yet. Not sure about using CDN because targeted users are in single region. I even face delay while testing with one host live with 3-4 viewers only.</p>
  <p>Any help will be appreciated.
  Thank You</p>