query: tag:GAE

GTUGのBootCamp 2011 Japan でGoogleAppEngineのセッションに参加してきました。

  • ハッシュタグは #bc2011jp #gae1

 最近HadoopやAWS方面に力を入れ始めているところなので、Googleのサービスの中でもGAEには興味があって、色々勉強したいと思ってます。かなり前にチュートリアルやった程度なのですっかり忘れてますし。。

 最近のGAEの話題としてはやっぱり新料金体系のことですね。場合によっては今までの20~30倍になるという話も聞きましたし。

 セッションでは節約の話の前に前半でまずGAEの概要やGAEがリクエストを処理する仕組みを説明していただいたので、節約の話もわかりやすかったです。

料金体系の変更としては簡単に言ってしまうと、

  • CPU Hours から Instance Hoursへ
  • APIも使用回数で課金(今まではCPU Hoursに含まれていた)

ということです。詳細はここでは説明しませんが。

 節約するには色々大変なことをしないといけないのかなぁと思っていましたが、どうやら設定を変更するだけでもかなり節約できるようですね。デフォルトの設定だとガンガンスケールアウトしていく設定らしいので、そこはしっかりチェックしておく必要がありますね。

 新料金については随分評判が悪いようですが、今までがほぼ無料だっただけに余計に高くなったように感じる部分もあるんではないかと思います。まだちゃんと使ってませんが、クラウド環境としてはかなりよい環境なのではないかと思うので、新料金の値段だけに気を取られるのではなく、節約するところは賢く節約して、有効活用していくのがいいかなぁと思います。個人で手軽に利用できるクラウド環境としてはすごく良いサービスだと思いますので。

IMAG0241.jpg

posted by akanuma akanuma on Sat 29 Oct 2011 at 22:36 with 0 comments

GAEなどでファイル数の多いライブラリを使うために、gemのパッケージから不要そうなファイルを消してjarファイルにまとめるために作ったスクリプトです。

ruby>>
#!/usr/bin/env ruby

def run(command)
puts command
system command
end

case ARGV[0]
when 'install'
run "jgem install -i ./gems --no-ri --no-rdoc #{ARGV[1]}"
when 'uninstall'
run "jgem uninstall -i ./gems #{ARGV[1]}"
end

Dir['gems/gems/'].each do |dir|
%w(
Generaters TODO README.
README
spec// test// examples// tasks//
tutorial// demo// website/**/*
CHANGES CHANGES.txt CHANGELOG
LICENSE MIT-LICENSE Rakefile CONTRIBUTORS
Manifest.txt History.txt install.rb setup.rb
).each do |pattern|
Dir[File.join(dir, pattern)].each do |path|
run "rm -rf #{path}"
end
end
end

Dir['gems/cache', 'gems/bin', 'gems/doc'].each do |path|
run "rm -rf #{path}"
end

run "jar cf lib/merb.jar -C ./gems ."
<<--

posted by genki genki on Mon 7 Sep 2009 at 19:14 with 2 comments

Hello, Merbists!

Today, I explain how to develop Merb apps that runs on GAE/J environment by using dm-datastore-adapter.

First of all, here is whole source code of an example app. Please check it out.

After checking it out,
you must edit appengine-web.xml file. Open it by editor and change the application name to yours.
And then you should make war directory by typing this command.

pre>>
MERB_ROOT% jruby -S warble war
<<--

It generates files under tmp/war.

So far, you are ready to deploy this app to GAE/J
Of course, you need an account of GAE/J to do it. Please get it in advance :-)

Let us go to deploy by this command.

pre>>
MERB_ROOT% appcfg.sh update -e {youraccount@gmail.com} tmp/war
<<--

This process takes a time for the first time.
If the log didn't say any errors, you got success!

Now your first Merb app on GAE/J is here at
http://{your app name}.appspot.com/

Congrats!

Further improvement is your home work :-p

APPENDIX

All required gems are being packed into jar file located at lib/merb.jar.
This enables you to pass the limit of which you can upload only 1000 files to GAE.
If you add more gems to the jar file, you can do it like this

  • unpacking it
  • add gems
  • and repack it

Enjoy!

posted by takiuchi takiuchi on Fri 24 Apr 2009 at 07:54 with 2 comments

JRubyで相対パスを含む場合に、Jarファイルの中のファイルを読めるようにするためのモンキーパッチの最新版です。

ruby>>
def cleanup_path(path)
if path.to_s.match(/^file:/) && path.is_a?(String)
jar_path, inner_path = path.split('!', 2)
inner_path = File.expand_path(inner_path)
path = [jar_path, inner_path].join('!')
end
path
end

alias :require_original :require
def require(path)
require_original cleanup_path(path)
rescue Exception => e
raise e unless path.to_s.match(/^file:/)
end

alias :load_original :load
def load(path)
load_original cleanup_path(path)
rescue Exception => e
raise e unless path.to_s.match(/^file:/)
end

class Dir
class << self
alias :aref_original :[]
def
aref_original *(args.map{|path| cleanup_path(path)})
end
end
end
class File
class << self
alias :mtime_original :mtime
def mtime(path)
if path.match(/^file:/)
jar_file, = path.split('!', 2)
path = jar_file.sub(/^file:/, '')
end
mtime_original(path)
end
end
end
<<--

posted by genki genki on Tue 21 Apr 2009 at 02:41 with 0 comments

GAEを使う上での大きな制限として、ファイル数1000までというのがあります。
これを乗り越えるために、unpackしたGemの中から不要なファイルを掃除したりする必要があったのですが、
関連するGem群をjarファイルにまとめる事でこの問題を乗り越えられます。

上記のファイルをlibの下に配置して、config/init.rb
あたりでrequire_fixを読み込みます。
これはjarファイルの中のrbファイルの読み込みに関するバグを
回避するためのものです。

実際に以下のサイトでmerb.jarを使って運用しています。

これによって、事実上ファイル数制限に左右されずにアプリケーションを開発する事が出来るようになります。
ただ、1ファイルのサイズ制限(10MB)が存在するので、jarファイルが大きくなりすぎた場合は分割する必要があります。

posted by genki genki on Sun 19 Apr 2009 at 08:25 with 0 comments

I shipped new dm-datastore-adapter today.

This update is a long jump from previous version. It includes following functions

  • Transaction. It utilizes the DataStore's Transaction API
  • OR conditions
    ruby>>
    Post.all(:id => [1,2])
    <<--
  • NOT conditions
    ruby>>
    Post.all(:id.not => 4)
    <<--

So now we can use most of functions defined in DM by using this adapter.

Enjoy!

posted by takiuchi takiuchi on Fri 17 Apr 2009 at 05:44 with 0 comments

DataMapper用のDataStoreアダプター、dm-datastore-adapter-0.2.2をリリースしました。

今回のリリースで以下のような機能がサポートされます。

  • トランザクション
  • OR条件
    ruby>>
    Post.all(:id => [1,2,3])
    <<--
    のような事が出来るようになりました。
  • NOT条件
    ruby>>
    Post.all(:updated_at.not => nil)
    Post.all(:id.not => 3)
    <<--
    などが出来るようになりました。

DataMapperのアダプタとして主に必要な機能はだいたい揃ってきました。

デモサイトであるWatchMe!もアップデートしています。

まだ実用的なサービスになってないですが、登録したサイトをクローリングして全てのページの監視を行い、エラーが発生したらメールで知らせるサービスになる予定です。

posted by genki genki on Fri 17 Apr 2009 at 04:29 with 8 comments

GAE/Jにはファイル数制限(1000まで)があるので、なるべく不要なファイルは減らしたいのが人情というものです。
ということで、unpackしたgemsから不要なファイルを掃除するために、以下のようなスクリプトを使用しています。

script/strip_gems

ruby>>
#!/usr/bin/env ruby

Dir['gems/gems/'].each do |dir|
%w(
Generaters TODO README.
README
spec// test// examples// tasks//
tutorial// demo//
CHANGES CHANGES.txt CHANGELOG
LICENSE MIT-LICENSE Rakefile CONTRIBUTORS
Manifest.txt History.txt install.rb setup.rb
).each do |pattern|
Dir[File.join(dir, pattern)].each do |path|
command = "rm -rf #{path}"
puts command
system command
end
end
end
<<--

Gemの中に含まれているファイルには制約が無いので、
簡単なパターンで全てを掃除するのは難しいですね。

posted by genki genki on Wed 15 Apr 2009 at 04:51 with 0 comments

dependencyでdata_objectsを指定すると、GAE/Jでなぜか突然exitしてしまうので理由を調べていたところ、data_objectsのtransaction.rbで以下のようなコードがあり、そこで落ちている事が分かりました。

ruby>>
module DataObjects

class Transaction
HOST = "#{Socket::gethostbyname(Socket::gethostname)[0]}" rescue "localhost"
<<--

Socket::gethostbyname を使っているところですね。

posted by genki genki on Tue 14 Apr 2009 at 04:25 with 0 comments

Today I shipped a new DataMapper plugin that enables us to easily develop Merb-apps been worked with GAE/J.

By using this plugin, you can seamlessly develop your Merb-apps between local and GAE/J environment.

For example, this site is powered by Merb/DM with the dm-datastore-adapter and running on the GAE/J

(This service is under construction :-p)

As a matter of fact, because it is still being alpha status,
you must treat various issues regarding gem dependencies yet.
I appreciate any kind of feedback and of course patches :-)

Enjoy!

posted by takiuchi takiuchi on Mon 13 Apr 2009 at 05:43 with 11 comments

DataMapper用のDataStore用アダプタ、dm-datastore-adapterを作りました。

これを使えば、MerbアプリをほぼそのままGoogle App Engine for Javaの上で動かせるようになります。
(実際にはgemの依存関係など、細かい調整が必要になりますが)

実際に以下のサイトでdm-datastore-adapterを使っています。

ローカル環境でも別なアダプタを利用すれば、普通のMerbアプリとして動作テストできるので、開発効率が飛躍的に向上します。

posted by genki genki on Mon 13 Apr 2009 at 05:37 with 0 comments

2日前ぐらいからいろいろ頑張ってたのですが、ようやくGAEjの本番環境でMerbアプリを動かせました。

http://jmerbist.appspot.com/

ss

使っているgemをfreezeする仕組みがあるフレームワークであれば、どれでも以外と簡単に動きそうな感じがします。

いやー、これは色々面白い事が出来そうですね!

posted by genki genki on Thu 9 Apr 2009 at 17:18 with 0 comments

Google App EngineでMerbを動かしてみた。

ss

しかし、本番環境にデプロイするためには別途Google App Engine Javaのアカウント申請が必要らしい。申請してみたけれど、レスポンスが無いので初回の10000万件の枠はもう無くなっている模様。

残念だなー。

posted by genki genki on Thu 9 Apr 2009 at 08:55 with 0 comments
posted by genki genki on Tue 15 Apr 2008 at 15:28 with 0 comments