HTTP Multipart Batched Request
HTTP Multipart Batched Request Nedir?
Çoklu ve bağımsız HTTP isteklerini tek istekte, çok parçalı
olarak yapmaya yarayan bir formattır.
Detaylı bilgi:
https://tools.ietf.org/id/draft-snell-http-batch-00.html
HTTP Multipart Batched Request’in Amacı
HTTP 1.1 üzerindeki bazı kısıtlamaları çözmeye yönelik,
sonradan ortaya çıkmış bir formattır.
HTTP Multipart Batched Request
HTTP Pipelining
POST /example/application HTTP/1.1
Host: example.org
Content-Type: multipart/batch;
type="application/http;version=1.1";
boundary=batch
Mime-Version: 1.0
--batch
Content-Type: application/http;version=1.1
Content-Transfer-Encoding: binary
Content-ID: df536860-34f9-11de-b418-0800200c9a66@example.org
POST /example/application HTTP/1.1
Host: example.org
Content-Type: text/plain
Content-Length: 3
Foo
--batch
Content-Type: application/http;version=1.1
Content-Transfer-Encoding: binary
Content-ID: 226e35d0-34fa-11de-b418-0800200c9a66@example.org
PUT /example/application/resource HTTP/1.1
Host: example.org
Content-Type: image/jpg
Content-Length: 123456
{jpg image data}
--batch--
Post
Content: Foo
Put
Content:
{jpg image data}
HTTP Multipart/Batch
Request Header
HTTP Multipart/Batch
Request Body
HTTP Multipart Batched Request Formatı
HTTP Multipart Batched Response Formatı
HTTP/1.1 200 OK
Date: Wed, 29 Apr 2009 20:00:00 GMT
Server: example.org
Content-Type: multipart/batch;
type="application/http;type=1.1";
boundary=batch
Mime-Version: 1.0
--batch
Content-Type: application/http;version=1.1
Content-Transfer-Encoding: binary
In-Reply-To: df536860-34f9-11de-b418-0800200c9a66@example.org
HTTP/1.1 204 OK
Date: Wed, 29 Apr 2009 20:00:00 GMT
Server: example.org
--batch
Content-Type: application/http;version=1.1
Content-Transfer-Encoding: binary
In-Reply-To: 226e35d0-34fa-11de-b418-0800200c9a66@example.org
HTTP/1.1 415 Unsupported Media Type
Date: Wed, 29 Apr 2009 20:00:00 GMT
Server: example.org
--batch--
HTTP Multipart/Batch
Response Header
HTTP Multipart/Batch
Response Body
Post
Response
Put
Response
Restful Endpoint Örnekleri
/users //Bütün kullanıcıları getir.
/users/{id} //id değeri x olan kullanıcıyı getir.
/orders //Bütün siparişleri getir.
/orders/{id} //id değeri x olan siparişi getir.
/porducts //Bütün ürünleri getir
/porducts/{id} //id değeri x olan ürünü getir.
/comments //Bütün yorumları getir
/comments/{id} //id değeri x olan yorumu getir.
Senaryo
Bir admin arayüzü yazıyoruz.
Dashboard ekranımız var.
Restful bir api üzerinden şu bilgiler isteniyor.:
1. Son eklenmiş olan 10 ürün.
2. Son verilmiş 10 sipariş.
3. Son kayıt olmuş 10 kullanıcı.
4. Son yazılmış 10 yorum.
1. Yöntem
/products (t)
/orders (t)
/users (t)
/comments (t)
HTTP İstek Sayısı: 4
Geçen Süre (t): 4
2. Yöntem
HTTP İstek Sayısı: 4
Geçen Süre (t): 1
Async Request
Async Response
3. Yöntem
HTTP İstek Sayısı: 1
Geçen Süre (t): 1
/get-dashboard
4. Yöntem
HTTP İstek Sayısı: 1 + 4
Geçen Süre (t): ~1
/get-dashboard
API
GATEWAY
5. Yöntem
HTTP İstek Sayısı: 1
Geçen Süre (t): ~1
/batch (n request with sub requests)
SubRequest Nedir?
Genelde Http Framework’lerinde implemente edilmiş bir özelliktir.
Yapay olarak istek oluşturmayaı ve hiç HTTP katmanına gitmeden
Oluşan bu istekleri işleme imkanı verir.
Silex
django-batch-requests 0.1.1 (Django package)
IdeasoftLabs/http-batch-bundle (Symfony Bundle)
IdeasoftLabs/http-batch-client (PHP Client)

Http Multipart Batch Request

  • 1.
  • 2.
    HTTP Multipart BatchedRequest Nedir? Çoklu ve bağımsız HTTP isteklerini tek istekte, çok parçalı olarak yapmaya yarayan bir formattır. Detaylı bilgi: https://tools.ietf.org/id/draft-snell-http-batch-00.html
  • 3.
    HTTP Multipart BatchedRequest’in Amacı HTTP 1.1 üzerindeki bazı kısıtlamaları çözmeye yönelik, sonradan ortaya çıkmış bir formattır.
  • 4.
    HTTP Multipart BatchedRequest HTTP Pipelining
  • 5.
    POST /example/application HTTP/1.1 Host:example.org Content-Type: multipart/batch; type="application/http;version=1.1"; boundary=batch Mime-Version: 1.0 --batch Content-Type: application/http;version=1.1 Content-Transfer-Encoding: binary Content-ID: df536860-34f9-11de-b418-0800200c9a66@example.org POST /example/application HTTP/1.1 Host: example.org Content-Type: text/plain Content-Length: 3 Foo --batch Content-Type: application/http;version=1.1 Content-Transfer-Encoding: binary Content-ID: 226e35d0-34fa-11de-b418-0800200c9a66@example.org PUT /example/application/resource HTTP/1.1 Host: example.org Content-Type: image/jpg Content-Length: 123456 {jpg image data} --batch-- Post Content: Foo Put Content: {jpg image data} HTTP Multipart/Batch Request Header HTTP Multipart/Batch Request Body HTTP Multipart Batched Request Formatı
  • 6.
    HTTP Multipart BatchedResponse Formatı HTTP/1.1 200 OK Date: Wed, 29 Apr 2009 20:00:00 GMT Server: example.org Content-Type: multipart/batch; type="application/http;type=1.1"; boundary=batch Mime-Version: 1.0 --batch Content-Type: application/http;version=1.1 Content-Transfer-Encoding: binary In-Reply-To: df536860-34f9-11de-b418-0800200c9a66@example.org HTTP/1.1 204 OK Date: Wed, 29 Apr 2009 20:00:00 GMT Server: example.org --batch Content-Type: application/http;version=1.1 Content-Transfer-Encoding: binary In-Reply-To: 226e35d0-34fa-11de-b418-0800200c9a66@example.org HTTP/1.1 415 Unsupported Media Type Date: Wed, 29 Apr 2009 20:00:00 GMT Server: example.org --batch-- HTTP Multipart/Batch Response Header HTTP Multipart/Batch Response Body Post Response Put Response
  • 8.
    Restful Endpoint Örnekleri /users//Bütün kullanıcıları getir. /users/{id} //id değeri x olan kullanıcıyı getir. /orders //Bütün siparişleri getir. /orders/{id} //id değeri x olan siparişi getir. /porducts //Bütün ürünleri getir /porducts/{id} //id değeri x olan ürünü getir. /comments //Bütün yorumları getir /comments/{id} //id değeri x olan yorumu getir.
  • 9.
    Senaryo Bir admin arayüzüyazıyoruz. Dashboard ekranımız var. Restful bir api üzerinden şu bilgiler isteniyor.: 1. Son eklenmiş olan 10 ürün. 2. Son verilmiş 10 sipariş. 3. Son kayıt olmuş 10 kullanıcı. 4. Son yazılmış 10 yorum.
  • 10.
    1. Yöntem /products (t) /orders(t) /users (t) /comments (t) HTTP İstek Sayısı: 4 Geçen Süre (t): 4
  • 11.
    2. Yöntem HTTP İstekSayısı: 4 Geçen Süre (t): 1 Async Request Async Response
  • 12.
    3. Yöntem HTTP İstekSayısı: 1 Geçen Süre (t): 1 /get-dashboard
  • 14.
    4. Yöntem HTTP İstekSayısı: 1 + 4 Geçen Süre (t): ~1 /get-dashboard API GATEWAY
  • 16.
    5. Yöntem HTTP İstekSayısı: 1 Geçen Süre (t): ~1 /batch (n request with sub requests)
  • 17.
    SubRequest Nedir? Genelde HttpFramework’lerinde implemente edilmiş bir özelliktir. Yapay olarak istek oluşturmayaı ve hiç HTTP katmanına gitmeden Oluşan bu istekleri işleme imkanı verir.
  • 18.
  • 20.
    django-batch-requests 0.1.1 (Djangopackage) IdeasoftLabs/http-batch-bundle (Symfony Bundle) IdeasoftLabs/http-batch-client (PHP Client)