Hi Ye,

No problems. Thanks for the update, I appreciate it.

In light of Doug's comments, I have also confirmed the same behaviour 
(success on writing 30KB; some hangs on writing >=32KBs) occurs with the 
latest release (r105) of the client library from SVN. I was expecting this, 
as it doesn't look like the GCS library is the problem.

Ben

On Thursday, September 19, 2013 5:47:08 PM UTC+1, Ye Yuan wrote:
>
> Ben,
>
> Speaking personally, thank you a lot for your posts! It is very helpful 
> for identifying this issue. I was focused on GCS client and wasn't aware of 
> the full scope. More people had been looped in and I'll reach out to other 
> relevant folks today. Very sorry for all the inconvenience!
>
> I tried fiddling this parameter, but this seems to cause too many requests 
> to GCS as I started receiving 503 responses, which corresponds to a request 
> rate that is too high (
> https://developers.google.com/storage/docs/reference-status#standardcodes
> ).
> GCS has a minimum chunk size of 256KB. Flushing data of smaller size has 
> undefined behavior.
>
>
> On Thursday, September 19, 2013 5:46:49 AM UTC-7, Ben Smithers wrote:
>>
>> A few more updates on this,
>>
>> It looks like Vinny was correct - writes of a smaller size do not seem to 
>> cause a problem. Specifically, writes from backend instances to datastore, 
>> blobstore and cloud storage of 32KBs all display the hanging behaviour I 
>> have been talking about. Writes to each of these of 30KBs all seem to work 
>> without problem (the actual size at which there is a problem seems to vary 
>> slightly depending on the service, presumably because of varying overhead - 
>> I have had full success with writes of 31.5KBs to datastore).
>>
>> My guess therefore is that there is some kind of block size used 
>> somewhere in the underlying urlfetch/RPC implementation and whenever 
>> multiple blocks are required for the request, there is some probability of 
>> the request hanging. Why this issue affects backend instances only, I have 
>> no idea.
>>
>> Using the deprecated files API for blobstore, it is possible to write 
>> large files simply by writing in chunks of 30KBs:
>>
>>     def write_in_chunks(self,data):
>>         chunk_size = 1024 * 30
>>         file_name = files.blobstore.create(mime_type="text/plain")
>>         num_chunks = int(math.ceil(len(data)/chunk_size))
>>         with files.open(file_name, 'a') as f:
>>             for i in range(0, num_chunks):
>>                 f.write(data[i*chunk_size:(i+1)*chunk_size])
>>         files.finalize(file_name)
>>
>> Using the cloudstorage library, this isn't possible. It looks like this 
>> is because the library only flushes data once 256K characters have been 
>> written; this can be seen in the write method in storage_api.py (the 
>> blocksize is set to 256K on line 489): 
>>
>>   def write(self, data):
>>     """Write some bytes."""
>>     self._check_open()
>>     assert isinstance(data, str)
>>     if not data:
>>       return
>>     self._buffer.append(data)
>>     self._buffered += len(data)
>>     self._offset += len(data)
>>     if self._buffered >= self._blocksize:
>>       self._flush()
>>
>> I tried fiddling this parameter, but this seems to cause too many 
>> requests to GCS as I started receiving 503 responses, which corresponds to 
>> a request rate that is too high (
>> https://developers.google.com/storage/docs/reference-status#standardcodes
>> ).
>>
>> Hopefully this is helpful for others and for identifying and fixing the 
>> underlying issue.
>>
>> Ben
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to